Motivation
I have the Mean
and StandardDeviation
of several lists of equal size but I don't know the elements of those lists.
I want to find what the Mean
and StandardDeviation
would be if I combined those lists together.
The Mean
of the combined lists is trivial, but I am finding the StandardDeviation
more complicated...
I am not very confident in the use of Solve
especially with statistical functions and so could use some help
Problem
Let r
be a list of real numbers of length m
, where m
is an even number. (r
is the combined list from above)
r
is partitioned into x
sublists of equal length where x
is an even number. (Call them r1
, r2
,...,rx
. The length of each ri
is n
).
How can I generate a function,f
, that generates the analytic solution that finds the StandardDeviation
of r
, given only:
the
Mean[r]
(call itu
)the
Mean
of each sublist,Mean[r1]
,Mean[r2]
...(Call itu1
,u2
...)and the
StandardDeviation
of each sublist,StandardDeviation[r1]
,StandardDeviation[r2]
...(Call its1
,s1
...)
ie. I want to find a function g[x_]
that generates f
Example
eg. we can solve this by hand for x=2
which gives
f[n_,u_,{s1_, s2_}, {u1_, u2_}] :=
Sqrt[(((n - 1)*(s1^2 + s2^2)) + n*(u1^2 + u2^2) - 2*n*u^2)/(2*n - 1)]
Check formula on an example
SeedRandom[1];
m = 100;
n = m/2;
r = RandomReal[{-1, 1}, m];
r1 = r[[;; n]];
r2 = r[[n + 1 ;;]];
u = Mean[r];
u1 = Mean[r1];
u2 = Mean[r2];
s1 = StandardDeviation[r1];
s2 = StandardDeviation[r2];
StandardDeviation[r] == f[n, u, {u1, u2}, {s1, s2}];
True
m
can be even or odd. $\endgroup$