A statistical random function
-
Hi, I am looking for a statistical random function that would allow me to supply the mean, min and max values. Something like: Double mean = 3; Double min = 1; Double max = 10; Double d = GenNext () Any help would be appreciated. :-D
-
Hi, I am looking for a statistical random function that would allow me to supply the mean, min and max values. Something like: Double mean = 3; Double min = 1; Double max = 10; Double d = GenNext () Any help would be appreciated. :-D
-
I don't know what "mean" would be ... but have you looked at the
Random
class? Q:What does the derived class in C# tell to it's parent? A:All your base are belong to us!Thanks for reply. Sorry for the confusion but here is the definition. Mean: The average of a set of N numbers. Yes I have, the best I could come up with is this: double h; double avg = 3.0, max = 10.0, min = 1.0; Random RandomClass = new Random (10); h = (- System.Math.Log(RandomClass.NextDouble())) * (avg - min); But this does not help with making sure the value doesn’t go over the max.
-
I don't know what "mean" would be ... but have you looked at the
Random
class? Q:What does the derived class in C# tell to it's parent? A:All your base are belong to us!CWIZO wrote:
I don't know what "mean" would be ... but have you looked at the Random class?
Mean is the average ((val1 + val2 + .. valN-1 + valN)/N ) value. Random has a designed mean of (MinVal+MaxVal)/2. To do what the OP wants where the mean could be located elsewhere would need a way to define the relative distribution. For the general implementation you'd need a parameter on the line of f(x) = where F(x) is defined over the range min..max and has a global maxima at mean. F(x) would scale the random value given a random value R. you'd return K defined that Integral(f(k), min value,k) = R. Integral f(x) would need scaled to normalize the return. For a specfic distribution you could try hardcoding it instead of taking a function as aparameter. You could try examing (large) 3rd party math libraries, but I suspect this is something that you'll need to write yourself. All of this is off the top of my head, and I don't know how to do the implementation.