Standard deviation in each quartile of a dataset

조회 수: 4 (최근 30일)
mickeymouse
mickeymouse 2022년 6월 11일
댓글: mickeymouse 2022년 6월 13일
Say I have a dataset (an array of 1 row by say, x, columns) that I want to divide into 4 quartiles.
How can I divide it into quartiles and compute the standard deviation of the data in each quartile, then plot the resulting standard deviations as a bar plot with the quartiles on the x-axis and standard deviation values on the y-axis?
Thank you in advance, all help is appreciated!

채택된 답변

Image Analyst
Image Analyst 2022년 6월 12일
Not sure what you mean by quartile but maybe it's 1/4 of the sorted data. If so, try this:
vec = sort(yourOriginalVector);
numElementsPerQuartile = numel(vec)/4;
stDev(1) = std(vec(1 : numElementsPerQuartile));
stDev(2) = std(vec(numElementsPerQuartile + 1 : 2 * numElementsPerQuartile));
stDev(3) = std(vec(2*numElementsPerQuartile + 1 : 3 * numElementsPerQuartile));
stDev(4) = std(vec(3*numElementsPerQuartile + 1 : end));
bar(stDev);
grid on
ylabel('Standard Deviation')
  댓글 수: 1
mickeymouse
mickeymouse 2022년 6월 13일
Thank you, this is exactly what I wanted to do!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by