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 visualizaciones (últimos 30 días)
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!

Respuesta aceptada

Image Analyst
Image Analyst el 28 de Nov. de 2016
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)

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by