How to make a normal distribution using the following parameters: mean, standard error, minimum, and maximum?

9 views (last 30 days)
I need to create a 400x1 array that contains a normal distribution with a mean of 100, minimum of around 50 and maximum of around 150. I also have a standard error value of 0.05. I have tried creating a random number generator using normfit with mu = 100 and SD = 0.05. However, this just gives me a distribution with 400 elements all +/- 0.05 away from 100. I need a distribution that has the highest frequency around 100 and the lowest/highest around 50 and 150, respectivley. The SE isnt as important to me.
  3 Comments

Sign in to comment.

Answers (1)

dpb
dpb on 19 Oct 2022
" have a standard error value of 0.05."
I have always heard "standard error" as being the std/mean -- using 0.05 as the standard deviation would imply
Z=(150-100)/0.05
Z = 1000
for which
1-normcdf(Z)
ans = 0
is so small as to be returned as identically zero.
OTOH, if it is a standard error of 5%, then the std dev would be 0.05*100 --> 5 and
Z=(150-100)/5
Z = 10
for which
1-normcdf(Z)
ans = 0
which is also still far too small for a normal to have any significant probability of values out that far.
The 95% Z values for a normal is
z=norminv([0.95 0.975])
z = 1×2
1.6449 1.9600
for one-sided or two-sided respectively, for which then the std deviation of your sampled distribution would need to be
s=(150-100)./z
s = 1×2
30.3978 25.5107
histfit(randn(400,1)*s(2)+100)

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!