Calculating the standard deviation of two weighted arrays.

just_matt

New Member
Joined
Aug 10, 2018
Messages
7
I have a formula that calculates the weighted average of two sets of data (F6:H6 and I6:K6) with weights defined in F3:H3 and I3:K3 respectively:
Excel Formula:
=SUMPRODUCT(F6:H6,$F$3:$H$3)*SUMPRODUCT(I6:K6,$I$3:$K$3)/(SUM($F$3:$H$3)*SUM($I$3:$K$3))

I am looking for a way to simplify my standard deviation calculation. Right now I can enter all data point calculations manually into a STDEV.P() or I can manually calculate the weighted standard deviation using:
Excel Formula:
=SQRT((SUM((F6*I6-$S$37)^2, (F6*J6-$S$37)^2*$G$3, (F6*K6-$S$37)^2, (G6*I6-$S$37)^2*$G$3, (G6*J6-$S$37)^2*$G$3*$J$3, (G6*K6-$S$37)^2*$G$3, (H6*I6-$S$37)^2, (H6*J6-$S$37)^2*$J$3, (H6*K6-$S$37)^2))/(SUM($F$3:$H$3)*SUM($I$3:$K$3)))
This returns 3.72015

My ask: Is there a way to simplify my standard deviation formula? OR ... am I doing this completely wrong?

ROW/COL
F
G
H
I
J
K
3
141141
6
1410.5.75.9

My weighted average for the dataset returns 7.8222. If I'm wrong there, then I have bigger problems.

My manually calculated STDEV.P returns 3.72015
Excel Formula:
=STDEV.P(F6*I6, F6*J6, F6*J6,F6*J6,F6*J6,F6*K6, G6*I6, G6*I6,G6*I6,G6*I6, G6*J6,G6*J6,G6*J6,G6*J6,G6*J6,G6*J6,G6*J6,G6*J6,G6*J6,G6*J6,G6*J6,G6*J6,G6*J6,G6*J6,G6*J6,G6*J6, G6*K6,G6*K6,G6*K6,G6*K6, H6*I6, H6*J6,H6*J6,H6*J6,H6*J6, H6*K6)

Sorry for not being able to upload a minisheet.
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
For the data you've posted, I get these results (assuming S37: =C3)

ABCDEFGHIJKL
1
2Weights1Weights2
3Av3.30141141
4StDev12.07
5StDev22.07Data1Data2
614100.50.750.9
7
Sheet1
Cell Formulas
RangeFormula
C3C3=SUMPRODUCT(F6:H6,$F$3:$H$3)*SUMPRODUCT(I6:K6,$I$3:$K$3)/(SUM($F$3:$H$3)*SUM($I$3:$K$3))
C4C4=SQRT((SUM((F6*I6-$S$37)^2, (F6*J6-$S$37)^2*$G$3, (F6*K6-$S$37)^2, (G6*I6-$S$37)^2*$G$3, (G6*J6-$S$37)^2*$G$3*$J$3, (G6*K6-$S$37)^2*$G$3, (H6*I6-$S$37)^2, (H6*J6-$S$37)^2*$J$3, (H6*K6-$S$37)^2))/(SUM($F$3:$H$3)*SUM($I$3:$K$3)))
C5C5=STDEV.P(F6*I6, F6*J6, F6*J6,F6*J6,F6*J6,F6*K6, G6*I6, G6*I6,G6*I6,G6*I6, G6*J6,G6*J6,G6*J6,G6*J6,G6*J6,G6*J6,G6*J6,G6*J6,G6*J6,G6*J6,G6*J6,G6*J6,G6*J6,G6*J6,G6*J6,G6*J6, G6*K6,G6*K6,G6*K6,G6*K6, H6*I6, H6*J6,H6*J6,H6*J6,H6*J6, H6*K6)

But before we tackle weighted standard deviation, what exactly do you mean by weighted average? Your formula makes no sense to me. For example, this configuration gives weighted average 20:

Weights1Weights2
111111
Data1Data2
222101010

And this one gives weighted average 30:

Weights1Weights2
111111
Data1Data2
333101010

Is there some logic here that I'm missing?
 
Upvote 0
UGH.

Transposition error on my side. The math is correct, the inputs I typed in were wrong, shifted left by one column when entering the data by hand on the board here. My sincere apologies.

ROW/COL
F
G
H
I
J
K
3
141141
6
41020.5.75.9
 
Upvote 0
Transposition error on my side.
No problem. I assumed that was what had happened.

My question was more about what your weighted average represented. But on closer look, I can see you're wanting to create a 3x3 data matrix and weightings, so please ignore my comments in post #2 about the logic.

I think this is what you're after?

ABCDEFGHIJKLM
1
2Weights1Weights2
3Av7.8222141141
4StDevP3.7201
5Data1Data2
6410200.50.750.9
7Demonstrating in steps ....
8
9Combined dataVarianceCombined weights
102.05.010.033.907.964.74141
113.07.515.023.250.1051.524164
123.69.018.017.831.39103.59141
13
14StDevP3.7201
15TRUE
16
Sheet1
Cell Formulas
RangeFormula
C3C3=SUMPRODUCT(F6:H6,$F$3:$H$3)*SUMPRODUCT(I6:K6,$I$3:$K$3)/(SUM($F$3:$H$3)*SUM($I$3:$K$3))
C4C4=SQRT(SUM((F6:H6*TRANSPOSE(I6:K6)-C3)^2*F3:H3*TRANSPOSE(I3:K3)/(SUM(F3:H3)*SUM(I3:K3))))
B10:D12B10=F6:H6*TRANSPOSE(I6:K6)
F10:H12F10=(B10-$C$3)^2
J10:L12J10=F3:H3*TRANSPOSE(I3:K3)
C14C14=SQRT(SUM(F10:H12*J10:L12)/(SUM(F3:H3)*SUM(I3:K3)))
C15C15=C14=C4
Press CTRL+SHIFT+ENTER to enter array formulas.


If you have the latest version of Excel, you won't need to array-enter any of these formulae. It's a good idea to update your Account details to let everyone know which version you're using, as the best solution may vary by Excel version.
 
Upvote 1
Solution
Excel Formula:
=SQRT(SUM((F6:H6*TRANSPOSE(I6:K6)-C3)^2*F3:H3*TRANSPOSE(I3:K3)/(SUM(F3:H3)*SUM(I3:K3))))

I sat too %&*#! close to the work to not see this. Now it's obvious. However I can say it probably would not have been obvious without your help. Greatly appreciated.
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,190
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top