How can I generate a random value based on a custom probability density function?
45 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have a custom probability density function that describes the probability of a variable "d" which falls within a range of 1:300.
I would like do define a function that would generate a random variable based on this custom pdf, similar to the function
rand
The code I have so far is
mu = 3.7;
sigma = 0.92;
d = 1:300;
PDF_dailydrivingdistance = ((1)./(d.*sigma.*sqrt(2*pi))).*(exp((-(log(d)-mu).^2)./(2*sigma^2)));
% need to randomly generate d based off of 'PDF_dailydrivingdistance'
0 comentarios
Respuestas (1)
SC
el 30 de Jun. de 2020
Editada: SC
el 30 de Jun. de 2020
Hey this might answer your question:
https://www.mathworks.com/matlabcentral/answers/430041-how-can-i-generate-random-numbers-according-to-a-known-probability
To know more about random number generation, visit the following link:
0 comentarios
Ver también
Categorías
Más información sobre Random Number Generation en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!