How can I create a custom probability distribution?
Mostrar comentarios más antiguos
I want to define a custom discrete probability mass function. Can I do this using `makedist` or perhaps some other function, if so how?
Respuesta aceptada
Más respuestas (1)
David Hill
el 18 de Feb. de 2022
Editada: David Hill
el 18 de Feb. de 2022
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 comentario
Categorías
Más información sobre Uniform Distribution (Continuous) en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!