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
John D'Errico 2017 年 6 月 11 日
編集済み: John D'Errico 2017 年 6 月 11 日

0 投票

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 件のコメント

Marsman
Marsman 2017 年 6 月 11 日
Thank you for your answer. I have tried splitting them up, but still cannot fit them well. I'm assuming this is because my weibull function(s) aren't in the form of the 'standard' Weibull function.

サインインしてコメントする。

質問済み:

2017 年 6 月 11 日

コメント済み:

2017 年 6 月 11 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by