Multinominal Discrete Discribution

Hi,

I’m not able to generate Samples from Multinominal distribution:
Example:

  • double[] weights = { 0.2, 0.2, 0.2, 0.2, 0.2 };
  • Multinomial multinomial = new Multinomial(weights, 1);
    var samples = multinominal.Samples().ToList(); // stackoverflow exception

Any help with this?

Thanks, in advance!

Hi

Samples() creates an infinite stream of samples. If you just want one sample, use Sample() instead - or for e.g. 10 samples, you can use Samples().Take(10).ToList().

Thanks,
Christoph

It’s clear now.

Thank you!