diff options
Diffstat (limited to 'gsl-1.9/doc/examples/randpoisson.c')
-rw-r--r-- | gsl-1.9/doc/examples/randpoisson.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/gsl-1.9/doc/examples/randpoisson.c b/gsl-1.9/doc/examples/randpoisson.c new file mode 100644 index 0000000..ef69b72 --- /dev/null +++ b/gsl-1.9/doc/examples/randpoisson.c @@ -0,0 +1,35 @@ +#include <stdio.h> +#include <gsl/gsl_rng.h> +#include <gsl/gsl_randist.h> + +int +main (void) +{ + const gsl_rng_type * T; + gsl_rng * r; + + int i, n = 10; + double mu = 3.0; + + /* create a generator chosen by the + environment variable GSL_RNG_TYPE */ + + gsl_rng_env_setup(); + + T = gsl_rng_default; + r = gsl_rng_alloc (T); + + /* print n random variates chosen from + the poisson distribution with mean + parameter mu */ + + for (i = 0; i < n; i++) + { + unsigned int k = gsl_ran_poisson (r, mu); + printf (" %u", k); + } + + printf ("\n"); + gsl_rng_free (r); + return 0; +} |