G
Guest
Hello,
I´ve to implement an array which sum always have to 1.
In the API Documentation I´ve found Random.NextDouble(),
but it always returns a value x with 0.0 <= x < 1.0.
Is there a range to specify the random value a bit more?
I want to do it like this:
double[] myArray = new Array();
Random randomClass = new Random();
double random=0.0, currentValue=0.0, restValue=1.0;
for(int i = 0; i < myArray.Length; i++)
{
random=randomClass.NextDouble(0.0, restValue);
restValue -= random;
myArray=restValue;
}
But this would only work if I would have a method like
NextDouble(double startValue, double endValue).
Do you have any ideas how to solve me problem?
Regards,
Martin
I´ve to implement an array which sum always have to 1.
In the API Documentation I´ve found Random.NextDouble(),
but it always returns a value x with 0.0 <= x < 1.0.
Is there a range to specify the random value a bit more?
I want to do it like this:
double[] myArray = new Array();
Random randomClass = new Random();
double random=0.0, currentValue=0.0, restValue=1.0;
for(int i = 0; i < myArray.Length; i++)
{
random=randomClass.NextDouble(0.0, restValue);
restValue -= random;
myArray=restValue;
}
But this would only work if I would have a method like
NextDouble(double startValue, double endValue).
Do you have any ideas how to solve me problem?
Regards,
Martin