How can I create a custom probability distribution?

I want to define a custom discrete probability mass function. Can I do this using `makedist` or perhaps some other function, if so how?

 채택된 답변

Paul
Paul 2022년 2월 18일

1 개 추천

Check out the doc page for distributionFitter and the associated Distribution Fitter app. Despite the name, the app can be used to define a custom distribution that you can subsequently use to create objects of that distribution.

추가 답변 (1개)

David Hill
David Hill 2022년 2월 18일
편집: David Hill 2022년 2월 18일
p = [0.2 0.3 0.5];%probabilities
v = [3 7 10];%discrete values
% P(X=3)=0.2, P(X=7)=0.3 and P(X=10)=0.5 Probability Mass Function
n = 10000;%number of samples
c = cumsum([0,p(:).']);
c = c/c(end);%ensure cumulative is 1
[~,i] = histc(rand(1,n),c);
r = v(i);%map, generates n samples with the probability mass function provided

댓글 수: 1

L'O.G.
L'O.G. 2022년 2월 18일
편집: L'O.G. 2022년 2월 18일
Thanks, but I don't think that's quite it. I guess I was unclear. Perhaps I should've said: I'd like to create a custom probability distribution object. I'd like to do that to be able to define a discrete pmf. That's why modifying makedist sounds like a possibility.

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

제품

릴리스

R2021b

태그

질문:

2022년 2월 18일

답변:

2022년 2월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by