Sign in to follow this  

reverse a probability distribution function

This topic is 4689 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

(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; }

Share this post


Link to post
Share on other sites
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 ].

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

This topic is 4689 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this