Let's say I have a range containing 200 values.
I'd like a formula that calculates the standard deviation of the top X of those values, where X is a value in a cell. For example, the standard deviation of the top 50 cells.
I'd also like a formula that, given a value in the range, calculates the standard deviation of the next X values in the range. For example, for value 15, the standard devation of values 15 - 15+x.
I feel confident that I can get the second formula on my own, given the first, but I'm blanking on how to do a standard deviation in this context. Average was a lot easier, using SUMIF
and LARGE
.
OK so the first part would look something like this:-
=STDEV(LARGE(A2:A11,ROW(INDIRECT("1:"&D2))))
where A2:A11 contains some test data and D2 contains how many, starting from the largest, you want to use in your calculation for which I am indebted to this
It's an array formula so has to be entered with Ctrl Shift Enter
If you had a certain value in your data (specified in D3) and wanted the stdev of that value and the next n-1 values in descending order (n specified in D4), the formula would look like this:-
=STDEV(LARGE(A2:A11,ROW(INDIRECT(RANK(D3,A1:A10)&":"&(RANK(D3,A1:A10)+D4-1)))))
If on the other hand you wanted to get the stdev of values between certain limits (specified in D5 and D6) you could use the original idea of setting non-used values to blanks using the following:-
=STDEV(IF((A2:A11>=D5)*(A2:A11<=D6),A2:A11,""))
So this example gives the same answer (stdev of 5 highest numbers) three different ways.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments