How to generate data based on uninvertible probability distribution function?
Afficher commentaires plus anciens
I want to generate data based on given probability distribution.
f(y) = alpha*exp(-y/beta1)+(1-alpha)*exp(-y/beta2)
I tried to use the way as follows. I used inverse function and reversed a probability distribution function to get the inverse result.
syms y
f(y) = alpha*exp(-y/beta1)+(1-alpha)*exp(-y/beta2);
g = finverse(f);
This method doesn't work since "Functional inverse cannot be found. " However, I find another code written by a programmer. This code can generate the data series perfectly. But I cannot understand its thought. Could you help me explain it?
m = [beta1;beta2]; % the two means
t = 1 + (randn(n,1)<alpha); % randomly select 1st or 2nd mean
X = m(t) .* -log(rand(n,1)); % generate exponentials with selected mean
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Uniform Distribution (Continuous) 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!