How to make a normal distribution using the following parameters: mean, standard error, minimum, and maximum?
Show older comments
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
Torsten
on 19 Oct 2022
I need a distribution that has the highest frequency around 100 and the lowest/highest around 50 and 150,
Unclear. If the highest frequency is around 100, then both at 50 and 150 are equal (usually low) frequencies.
Sean
on 19 Oct 2022
Torsten
on 19 Oct 2022
Then play with the variance to get the histogram you like.
If the random numbers must all lie in [50 150], use a truncated normal:
Answers (1)
" 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
for which
1-normcdf(Z)
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
for which
1-normcdf(Z)
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])
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
histfit(randn(400,1)*s(2)+100)
Categories
Find more on Encryption / Cryptography in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!