Draw random number from a truncated distribution with upper bound
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello everyone,
how can I draw a random number from a truncated normal distribution with mean 0 and varying var (sigma^2)? The upper bound of the truncation value varies within my time series. What I did first is to specify the probability distribution for the different variance values (1xn matrix). After that, I draw a truncated normal distribution for each "row"/ new upper bound. Since I have a huge time series, this step takes forever.
for i = 1:size(pd,2);
t(:,i) = truncate(pd(size(pd,1),i),-inf,upperBound(:,i)));
end
Whenever, this step would be executed I would draw a random number out of each truncated distribution, using
r = random(t(:,1),1);
However, I am not sure if that will work, though.
Is there a way to predefine the matrix for the specification of t? A normal zero/nan etc. matrix doesnt work. And how can I speed up the process to draw from a truncated normal distribution with varying upper bound values?
0 Kommentare
Akzeptierte Antwort
Torsten
am 23 Okt. 2017
https://de.mathworks.com/matlabcentral/fileexchange/53180-truncated-normal-generator
Best wishes
Torsten.
5 Kommentare
Torsten
am 24 Okt. 2017
u=10;
s=1;
m=3;
U=normcdf(u);
n=100;
X=rand(n,1);
Y=m+s*norminv(X*U);
produces n random numbers taken from the normal distribution N(m,s^2) truncated at the upper bound u.
Can you take it from here ?
Best wishes
Torsten.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!