Gamma deviates


Ida_And
06-21-2006, 11:09 AM
Hi,

I have been trying to produce gamma deviates in C++ according to the algorithm outlined in NR. However, it doesn't seem to working. Seems like the program reuses the same numbers over and over again, like it doesn't produce new random draws. What could be the problem?
I've included a small piece of my code below, the for loop producing the deviates. The rest of the code is identical to the book:

int main()
{
double x[100];
for(int q=0;q<100;q++)
{
double val = 17.4;
x[q]=gamdev(4.02,val);
cout<<x[q]<<endl;
}
return 0 ;
}

Best regards,

Ida