Closed benjamin-lieser closed 1 year ago
That design could work, though there is probably very little reason for the enum
: users will already need to choose between static or dynamic constructors. If the point is to be able to return a generic object sampling from [I; K]
or [I]
— you still can't do this without a unified output (sample) type (e.g. by converting [I; K]
to Vec<I>
— was this how you planned to implement Distribution<_>
)?
Honestly, the fact I took so long to answer reflects the currently rather limited interest in maintaining, let alone expanding, rand_distr
. I'll close this issue because I don't want to track it, but feel free to ask further questions or open a PR (I'll try at least to answer questions more promptly).
I am in the process of writing an implementation for the Multinomial distribution. The structure is similar to the one of the Dirichlet distribution. But I want to support const generic (number of categories known at compile time) and dynamic number of categories.
I think having Multinomial as an enum is a good idea, because depending on the number of draws different sampling strategies might be optimal and we can be generic over dynamic and static number of categories.
For the dynamic allocation the K parameter would be 0.
What do you think? In the future we could maybe do with one new function which selects depending if
K==0
, but as far as I know current stable Rust does not support this.Also how to take the weight parameter? Especially for the dynamic case something like
W : IntoIterator<Item=F>
seems fitting.