visual studio 2013 - use beta distribution from mathdotnet in C# in VS2013 -


i ma using mathdotnet form c# in vs2013.

i need generate sequence of samples

ienumerable<double> samples(double a, double b) 

at

http://numerics.mathdotnet.com/api/mathnet.numerics.distributions/beta.htm#samples 

i not know how control sample size. exmaple, need 5000 smaple points distribution.

this c# code:

  beta betadistr = new beta(alpha, beta);   list<double> sample = betadistr.samples(alpha, beta);  

what size of sample ?

and difference between

 ienumerable<double> samples(double a, double b) 

and

  ienumerable<double> samples(random rnd, double a, double b) 

how use rnd control sample ?

thanks

the distributions offer 2 ways generate multiple samples in 1 go:

  • sample() returns infinite sequence. allows lazy evaluation. take many need, on demand.
  • sample(array) fills array completely. fastest if whole array needed.

so, if strictly need ilist<double> 5000 samples, can either:

beta beta = new beta(alpha, beta); list<double> samples = beta.samples().take(5000).tolist(); 

or

beta beta = new beta(alpha, beta); double[] samples = new double[5000]; beta.samples(samples); 

if don't need beta instance else, can simplify using static routines, work same way:

list<double> samples = beta.samples(alpha, beta).take(5000).tolist(); 

or

double[] samples = new double[5000]; beta.samples(samples, alpha, beta); 

for of theses variations can provide own random instance, or one of provided math.net numerics. in case of class instance can pass constructor, in case of static routines there overload accepting first argument. see probability distributions more details.


Comments