How to generate random variables for a custom function
Afficher commentaires plus anciens
I have a model for a failure phenomena decribed as:
a1 = 0.2115;
a2 = 1-a1;
b1 = 0.9017;
b2 = 1.0710;
t1 = 57.9715;
t2 = 4837.3947;
PNZ = 0.8147;
t = 1:1:1101;
r_t = a1.*exp(-(t/t1).^b1)+PNZ.*a2.*exp(-(t/t2).^b2);
It is based on a 2-Weibull mixture function. I would like to generate random variables of this phenomena to later perform a Monte Carlo simulation. I've tried to fit the function to a standard weibull pdf in order to use a simple rand function for random number generation, however I would end up with this:

So, does anyone know a method to generate random variables from this custom function?
Réponses (1)
John D'Errico
le 11 Juin 2017
Modifié(e) : John D'Errico
le 11 Juin 2017
You appear to be trying to take a mixture of two Weibulls, and fit it, then use the result to generate a random variable. Don't do that.
A mixture distribution means that with probability p, generate a variate from distribution 1. With probability 1-p, generate from distribution 2.
So just generate a uniform random variable. If the result is less than p, use distribution 1. You can even do this in a vectorized form.
help rand
1 commentaire
Marsman
le 11 Juin 2017
Catégories
En savoir plus sur Weibull Distribution dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!