I've been considering this for a while. Would it make sense to define a new struct, a weighted_array, which contains both an array and a set of weights? The primary advantages are as follows:
- The weighted array can be stored contiguously in memory as an array of
(element, weight) tuples. Weights and array elements are almost always accessed together, so this allows for faster access.
- Allows
weighted_arrays to be passed as a single argument in place of an array.
- The user can conveniently manipulate weights together with observations. For example, dropping missing values would also automatically drop the weights associated with them.
(The old interface can also be kept.)
I've been considering this for a while. Would it make sense to define a new struct, a
weighted_array, which contains both an array and a set of weights? The primary advantages are as follows:(element, weight)tuples. Weights and array elements are almost always accessed together, so this allows for faster access.weighted_arrays to be passed as a single argument in place of an array.(The old interface can also be kept.)