Hi community,
I would like to make a normal random distribution for a demand set in Matlab with a range from [0 100]. However, I can not come up with a good working good yet. Does anyone have an idea how to do this?
Thankyou,

댓글 수: 2

Rik
Rik 2019년 4월 24일
A normal distribution has no edges and is continuous. What should happen with the values outside of your range, and is it OK if the values are not integers?
bus14
bus14 2019년 4월 24일
preferably values should be integers as it concerns ordering of products. It would also be fine if the values be in the 100s. However values of 1000+ I cannot use

댓글을 달려면 로그인하십시오.

 채택된 답변

Rik
Rik 2019년 4월 24일

0 개 추천

You can use the randn function to generate random numbers.
n=300;%number of cases
minval=0;%lowest allowed integer
maxval=1000;%highest allowed integer
mu=50;%median value of distribution
sd=50;%standard deviation of distribution
data=floor(mu+sd*randn(n,1));%round down to integers
invalid= data<minval | data>maxval;
while any(invalid)
%replace invalid values with newly generated values
%this will bias the distribution
data(invalid)=floor(mu+sd*randn(sum(invalid),1));
invalid= data<minval | data>maxval;
end

댓글 수: 3

bus14
bus14 2019년 4월 25일
thanks for the code.
Can you now say that it these numbers are still randomly distributed under normal distribution. Or does this not hold any more due to the replacement of variables that are initially beyond the bounds?
Rik
Rik 2019년 4월 25일
Technically if replacement of values is needed it will no longer be a normal distribution. The difference between the actual distribution and a normal distribution will depend on the bounds and on the median and standard deviation of the initial distribution. As long as the bounds are more than 3 SDs away from your median I would still be comfortable calling it a normal distribution, but that conclusion depends on your specific application.
By having bounds, you effectively remove parts of the tails of the distribution. How relevant that is depends on your goal and application. If it is important, ask a statistician for help.
bus14
bus14 2019년 4월 25일
Thankyou!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

질문:

2019년 4월 24일

댓글:

2019년 4월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by