Standard Deviation formula linear form

조회 수: 10 (최근 30일)
Igor Bogdanov
Igor Bogdanov 2020년 8월 16일
댓글: Walter Roberson 2020년 8월 16일
Hello! Have an array X=1xN. How to write the standard deviation formula in matlab (not to use the ‘std’ function)? I know the formula itself, but how is it written in a "linear" form? Thanks! My results is this:
sqrt = ((sum(sum(X)-mean(X)).^2)/(numel(X)-1))
Please, help to find mistake

답변 (1개)

Walter Roberson
Walter Roberson 2020년 8월 16일
You are assigning the result to a variable named sqrt instead of taking the square root of something.
You should not be taking sum(X) and subtracting the mean from that: you should be taking the sum of (squares of (X minus mean))
  댓글 수: 2
Igor Bogdanov
Igor Bogdanov 2020년 8월 16일
Let me see if I understand this.
standdev = sqrt((sum((X)-mean(X)).^2)/(numel(X)-1))
Walter Roberson
Walter Roberson 2020년 8월 16일
  1. calculate X - mean(X)
  2. take squares of that vector
  3. sum result
  4. calculate number of elements in X, minus 1
  5. divide the sum by that
  6. take the square root of the result of the division
If you go through your code carefully you will see this is not what you are doing.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by