Set boundaries for norminv output

조회 수: 4 (최근 30일)
Marc Jakobi
Marc Jakobi 2015년 7월 27일
답변: Torsten 2015년 7월 27일
Hi.
I am trying to generate randomized data with a certain average and a standard deviation. However, the data has to be within a realistic range.
My attempt so far has been as follows:
JV = norminv(rand(dim),4700,1500); %dim is the dimensions of the output
The problem with this method is that I have to manually limit the output:
JV(JV < 1000) = 1000;
JV(JV > 9000) = 9000;
The mean and standard deviation are still within an acceptable range. However, due to the manual limitation, the histogram shows sudden "jumps" in the amounts at the bins 1000 and 9000.
Is there a way I can set the boundaries within norminv, so that I get a "clean" histogram?
Thanks!
- Marc
UPDATE: I found a solution:
P1 = normcdf(1000,4700,1500);
P2 = normcdf(9000,4700,1500);
JV = norminv(P1+(P2-P1).*rand(dim),4700,1500);
This "cleans up" the histogram. But of course the standard deviation is slightly smaller than 1500, since a strictly gaussian distribution is not possible within a limited interval.

채택된 답변

Torsten
Torsten 2015년 7월 27일
Use a truncated normal distribution:
Best wishes
Torsten.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Histograms에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by