Need help manually finding the standard deviation using an external function

I am new to matlab (taking an intro to matlab class), but for my assignment I have to do a number of things including randomly generating 10 scores for each of 25 students. Then take the median, mean, and standard deviation for each student's scores. For median and mean I used median(Score,2) and mean(Score,2) to find the values for each row (individual student's 10 scores). I am struggling to figure out how to manually find the standard deviation for each student. I also have to use Matlab functions to find the std and compare it to the manual calculation. The part I am inquiring about is part D in the code. I know I probably dont have it right at all this is just my starting point from looking stuff up online. Any help would be appreciated, thanks.

 採用された回答

Ameer Hamza
Ameer Hamza 2020 年 10 月 2 日
編集済み: Ameer Hamza 2020 年 10 月 2 日
It should be something like this
z = sqrt(1/N*sum((Score - mean_student).^2, 2))

5 件のコメント

Kelley Kehoe
Kelley Kehoe 2020 年 10 月 2 日
thank you so much!!
Ameer Hamza
Ameer Hamza 2020 年 10 月 2 日
I am glad to be of help!
Kelley Kehoe
Kelley Kehoe 2020 年 10 月 2 日
So i entered what you gave me and it seems it is almost correct, but the two arrays of standard deviation are slightly off from eachother, do you think that is due to the z function or the std(Score,0,2) command?
Ameer Hamza
Ameer Hamza 2020 年 10 月 2 日
MATLAB uses following formula for std
The difference is division by N-1 in this case. In your formula, there is a division by N. This is an unbiased estimator of standard deviation. Your formula is a biased estimator. Both are equally valid, and you should use the one given to you. Read the discussion here: https://en.wikipedia.org/wiki/Standard_deviation#Estimation.
You cannot make the MATLAB's std result match your formula.
Kelley Kehoe
Kelley Kehoe 2020 年 10 月 3 日
Thanks! For a later part of the assignment I have to use that same z function but the input is the vector of means for each student, I am supposed to get an output of a single number but I am getting a 25x1 vector output similiar to the first function. Any thoughts on this?
This is my attempt:
formula_std_class_mean = sqrt(1/N*sum((mean(Score,2) - class_mean_grade).^2, 2)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeGet Started with MATLAB についてさらに検索

製品

リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by