a flat distribution

J

Joseph

I have following code which I want to generate random numbers of a flat
distribution but something wrong with my code ,it does output in the
range 1-12

========================
#include <gsl/gsl_rng.h>
#include <gsl/gsl_randist.h>

int main (void)
{
const gsl_rng_type * T;
gsl_rng * r;

r = gsl_rng_alloc (gsl_rng_mt19937);
for (int i = 0; i < 10; i++)
{

double v = gsl_ran_flat(r, 1,12);
printf("number is %d\n ",v);

}

gsl_rng_free (r);

return 0;
}

=========================

is it possible to be the compliation pramater's problem ?

I use: g++ filename -lgsl -lgslcblas -lm





Thanks a lot!!
 
J

JosephWu

I have following code which I want to generate random numbers of a flat
distribution but something wrong with my code ,it does output in the
range 1-12

========================
#include <gsl/gsl_rng.h>
#include <gsl/gsl_randist.h>

int main (void)
{
const gsl_rng_type * T;
gsl_rng * r;

r = gsl_rng_alloc (gsl_rng_mt19937);
for (int i = 0; i < 10; i++)
{

double v = gsl_ran_flat(r, 1,12);
printf("number is %d\n ",v);

}

gsl_rng_free (r);

return 0;
}

=========================

is it possible to be the compliation pramater's problem ?

I use: g++ filename -lgsl -lgslcblas -lm





Thanks a lot!!



I found out that the default lib dir is /usr/local/lib but on my linux
(Mandrake 10) the lib files are all installed in the /usr/lib


how can i point the compiler to the dir where it could seek for the lib
files?


the topic is covered here
http://www.gnu.org/software/gsl/manual/gsl-ref_2.html#SEC11


which in most case I need to do like this:
gcc demo.c -lgsl -lgslcblas -lm (found
here:http://www.gnu.org/software/gsl/manual/gsl-ref_19.html#SEC325)

the GSL reference manual says that I need to create the path for lib
files(http://www.gnu.org/software/gsl/manual/gsl-ref_2.html#SEC12)

how can I do that ?
am I on the right way for the solution of my code ?

Thanks a lot
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top