Question on how to calculate the variance and then standard deviation on an interval from a to b with 100 samples of size 225 random numbers
2 次查看(过去 30 天)
显示 更早的评论
nsamples=100;
samplenum = 1:nsamples;
%setting number of samples and the sample amt. i.e. here there
%is only 1 sample of number 100
n = 225;
%sample size 225
a = 1;
%setting first mean value of 1
b = 2;
%setting second mean value of 2
a + (b-a)*rand()
%gives uniform random values in the interval [a,b]
((b-a)^2)/100
%calculating variance
d = (b-a)/sqrt(100)
%calculating standard deviation
Hi, so here I am wondering to calculate the variance and standard deviation should i be using:
(samplenum) instead of (b-a)?
I'm trying to generate 100 samples and then find the standard deviation
Also this part of the code:
c = (b+a)/2
%calculating mean of values of mean between a and b
should be calculating the mean values between a and b?
Thank you!
0 个评论
采纳的回答
Image Analyst
2016-11-28
Why not use mean(), var(), and std()?
Your c is not using any actual values. You need to do something like
data = a + (b-a)*rand(1, nsamples);
cMean = mean(data)
cStdDev = std(data)
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!