How to generate random variables for a custom function
显示 更早的评论
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?
回答(1 个)
John D'Errico
2017-6-11
编辑:John D'Errico
2017-6-11
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
类别
在 帮助中心 和 File Exchange 中查找有关 Weibull Distribution 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!