2

I want to generate random number from a weibull distribution with given shape and scale factor. I used the below code but the values generated are always close to beta. How to change the range of values?

public double weibull(double eta, double beta)              
{               
    RandomGenerator rg = new JDKRandomGenerator();
    WeibullDistribution g= new WeibullDistribution(rg, eta, beta, WeibullDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY);
    return g.sample();
}
pjs
  • 18,696
  • 4
  • 27
  • 56

1 Answers1

1

If this is the WeibullDistribution from the Apache commons distribution, the second and third arguments to the constructor you used are a shape parameter and a scale parameter, respectively. Values of the shape parameter above 2 or so will tend to give outcomes close to the scale parameter. If you don't want that, change the shape parameter.

Please note that you should not be constructing a new rg and new WeibullDistribution object each time you invoke your method. Make both of those static and re-use them.

pjs
  • 18,696
  • 4
  • 27
  • 56