J
Jon Agiato
Hello,
I am sure this problem is easy to spot but I have been at this project all
day and the frustration has finally overcome me. I am using this function
in order to produce a standard normal distribution random number generator
and then using the function in another part of my program in order to use
the value. This function is called for many iterations. The problem is,
through each run I am getting the exact same number generated from this
function with the occasional slight variation. How can I make this function
create numbers randomly? I am thinking since it is being run so fast the
same seed is being used, but how can I change that? This is C# code, used
in a web application. Here's the code:
private double sndRNG()
{
const double quantityRN = 16.0;
uint start = 0;
double tmp = 0.0;
Random randomNumber = new Random();
for(; start != quantityRN; ++start)
{
tmp += Convert.ToDouble(randomNumber.Next(10));
}
double tmp2 = tmp / quantityRN;
return (tmp2 - 4.5) * 4.0 / Math.Sqrt(8.25);
}
Thanks for any and all suggestions.
I am sure this problem is easy to spot but I have been at this project all
day and the frustration has finally overcome me. I am using this function
in order to produce a standard normal distribution random number generator
and then using the function in another part of my program in order to use
the value. This function is called for many iterations. The problem is,
through each run I am getting the exact same number generated from this
function with the occasional slight variation. How can I make this function
create numbers randomly? I am thinking since it is being run so fast the
same seed is being used, but how can I change that? This is C# code, used
in a web application. Here's the code:
private double sndRNG()
{
const double quantityRN = 16.0;
uint start = 0;
double tmp = 0.0;
Random randomNumber = new Random();
for(; start != quantityRN; ++start)
{
tmp += Convert.ToDouble(randomNumber.Next(10));
}
double tmp2 = tmp / quantityRN;
return (tmp2 - 4.5) * 4.0 / Math.Sqrt(8.25);
}
Thanks for any and all suggestions.