How to calculate mean and standard deviation
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
1 개 추천
Hi everyone, want to ask.
If I have set of data let say
X = [23,43, 45,90,15,41,71,29,45,52,32];
How to calculate the mean and standard deviation?
채택된 답변
Star Strider
2019년 12월 18일
댓글 수: 10
Oh so simple. Thank you star strider
My pleasure.
If my Answer helped you solve your problem, please Accept it!
But std not give the value
My data must be single not double. What means?
This works when I run it:
X = [23,43, 45,90,15,41,71,29,45,52,32];
Xmean = mean(X) % Double
Xstd = std(X) % Double
Xmean = single(mean(X)) % Single
Xstd = single(std(X)) % Single
producing:
Xmean =
44.181818181818180
Xstd =
21.381385277002899
Xmean =
single
44.1818199
Xstd =
single
21.3813858
Mohd, you say your data must be single. That's an error you'll get if your data is uint8, like it came from an image, and try to use std() -- it will say your data must be single or double. So just cast your data to single or double and it will work fine:
X = uint8([23,43, 45,90,15,41,71,29,45,52,32])
meanX = mean(single(X))
stdX = std(single(X))
X =
1×11 uint8 row vector
23 43 45 90 15 41 71 29 45 52 32
meanX =
single
44.18182
stdX =
single
21.38139
Thank you star strider and image Analyst. Will try tonight.
As always, our pleasure!
the standard deviation of those valuse are 20.386350967869, why MATLAB returns 21.38139?
As you know, there are two standard deviations
- the standard deviation of the sample
- the standard deviation of the population
If you want the non-default formula, you have to tell it:
X = [23,43, 45,90,15,41,71,29,45,52,32];
sd = std(X) % Default
s0 = std(X, 0)
s1 = std(X, 1)
sd =
21.3813852770029
s0 =
21.3813852770029
s1 =
20.3863509678688
S = std(A,w) specifies a weighting scheme for any of the previous syntaxes. When w = 0 (default), S is normalized by N-1. When w = 1, S is normalized by the number of observations, N. w also can be a weight vector containing nonnegative elements. In this case, the length of w must equal the length of the dimension over which std is operating.
추가 답변 (1개)
MD Ashraful Islam
2022년 1월 27일
mean(X)
std(X)
카테고리
도움말 센터 및 File Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
