How to generate random variables for a custom function

조회 수: 5 (최근 30일)
Marsman
Marsman 2017년 6월 11일
댓글: Marsman 2017년 6월 11일
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일
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.

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by