How can I create a custom probability distribution?
26 次查看(过去 30 天)
显示 更早的评论
采纳的回答
Paul
2022-2-18
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.
0 个评论
更多回答(1 个)
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
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!