How to generate random variables for a custom function

5 visualizzazioni (ultimi 30 giorni)
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?

Risposte (1)

John D'Errico
John D'Errico il 11 Giu 2017
Modificato: John D'Errico il 11 Giu 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 Commento
Marsman
Marsman il 11 Giu 2017
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.

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by