reverse a probability distribution function
(Sorry for the previous untitled post)
I'm trying to figure out how to 'reverse' a probability distribution function. In particular a 2-parameter Weibull pdf.
(see http://www.weibull.com/LifeDataWeb/weibull_probability_density_function.htm)
I have written a java method which implements a distribution function (see java code below)
So if I call the method with this input:
K = 2.851300069247714 C = 7.596157491862076, (these values derived from the data set) and a U =7, it returns 0.14612429022044235
This means that there is a ~14% chance of getting a 7
What i really need is the reverse where it returns a value that would be likely based on the distrubution, similar to if i called java.lang.Math.rand();
How do i do this, mathematically?
/**
* calculateWeibull
*
* calculates the weibull distribution
*
* @param U
* @param K shape factor
* @param C scale factor
*
* @return Returns the value of the distribution at U
*/
public double calculateWeibull (double U,
double K, // shape
double C) // scale
{
double Pudu = 0.0;
double firstHalf = 0.0;
double secondHalf = 0.0;
firstHalf = (K/C) * Math.pow(U/C, K-1);
secondHalf = Math.exp( (-Math.pow(U/C, K)));
Pudu = firstHalf * secondHalf;
return Pudu;
}
A simple way is to calculate a random value r1 uniformly distributed in [0,1] and another value r2 uniformly distributed over valid values of U e.g maybe 1,2,..10 in your example. If r1<pdf(r2) then return r2 else repeat. It won't be very fast, but it'll work.
However, your U seems to be continuous and then P(U=U1) for any U1 is 0. You have to integrate over an interval to get a probability, i.e P(U in [U1,U2])=integral(U1,U2)[ pdf(x) dx ].
However, your U seems to be continuous and then P(U=U1) for any U1 is 0. You have to integrate over an interval to get a probability, i.e P(U in [U1,U2])=integral(U1,U2)[ pdf(x) dx ].
Well, it can be nontrivial (i don't know this transformtion). But you should at least understand what you are doing.
You have a random variable X in R(0,1) (that is uniformly distributed in [0,1], it can be measured with the rand() function). And you want to convert this random variable into a weibull distribution.
For example, to transform a uniformly distributed varible into a normal distribution a so called Box-Muller transformation can be done:
http://mathworld.wolfram.com/Box-MullerTransformation.html
But as I said, the transformation from a uniformly distributed variable to a weibull distr. can be very hard and perhaps it can only be done numerically.
Regards
You have a random variable X in R(0,1) (that is uniformly distributed in [0,1], it can be measured with the rand() function). And you want to convert this random variable into a weibull distribution.
For example, to transform a uniformly distributed varible into a normal distribution a so called Box-Muller transformation can be done:
http://mathworld.wolfram.com/Box-MullerTransformation.html
But as I said, the transformation from a uniformly distributed variable to a weibull distr. can be very hard and perhaps it can only be done numerically.
Regards
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement