Does anyone know how to create a custom distribution?
이전 댓글 표시
the thing is, i want to define a custom distribution in statistic toolbox,the custom distribution is like this pdf = (1-p)*normalpdf +p*exppdf, it's a combination of two distribution.
there is an example from matlab,it's laplace distrbution, but i want a combination of two distributions.it's hard for me . Could someone give me an idea ?
답변 (2개)
Image Analyst
2013년 1월 27일
0 개 추천
Try this link: http://www.mathworks.com/matlabcentral/fileexchange/7309-randraw. It has numerous distributions, along with source code so you can see how it's done.
Tom Lane
2013년 1월 27일
You have a four-parameter distribution with density
(1-p)*normpdf(x,mu,sigma) + p*exppdf(x,lambda)
and with a cdf that is similarly a linear combination of normcdf and expcdf. You can generate random numbers from it by take the normal value with probability (1-p) and the exponential value with probability p. The inversecdf is trickier but you might find fzero to be helpful:
>> p = .6; mu = 0; sigma = 1; lambda = 3;
>> mycdf = @(x) (1-p)*normcdf(x,mu,sigma) + p*expcdf(x,lambda);
>> mycdf(1.5)
ans =
0.6094
>> fzero(@(y) mycdf(y)-.6094,1)
ans =
1.5002
카테고리
도움말 센터 및 File Exchange에서 Exponential Distribution에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!