1
$\begingroup$

I have a histogram representing the PDF (probability density function) of an unknown discrete RV. The histogram is asymmetrical. Is there a known way in Mathematica to increase/decrease the variance of the distribution while preserving the Mean?

Thanks

$\endgroup$
1
  • $\begingroup$ Scale each point x -> k (x - mean)? $\endgroup$ Jan 27, 2015 at 17:22

1 Answer 1

3
$\begingroup$
mpsF[k_] := Mean[#] + N@Sqrt[k] (# - Mean[#]) &; (* thanks: ybeltukov *)

Example:

dist = BinomialDistribution[40, .1];
sample = N@RandomVariate[dist, 100];
sample2 = mpsF[10][sample];

Through@{Mean, Variance}@sample
(* {4.18, 4.57333} *)
Through@{Mean, Variance}@sample2
(* {4.18, 45.73333} *)

Alternatively, define a function to apply a mean-preserving-spread transformation to a distribution:

mpsTDF[k_] := TransformedDistribution[Mean @ # + Sqrt[k] (z - Mean @ #), Distributed[z, #]] &

Examples:

Through@{Mean, Variance}@ mpsTDF[3][NormalDistribution[μ, σ]]
(* {μ, 3 σ^2} *)

Through@{Mean, Variance}@# & /@ {ChiSquareDistribution[ν], mpsTDF[3][ChiSquareDistribution[ν]]}
(* {{ν, 2 ν}, {ν, 6 ν}} *)
$\endgroup$
2
  • $\begingroup$ +1, A bit more readable Mean[#] + N@Sqrt[k] (# - Mean[#]) & $\endgroup$
    – ybeltukov
    Jan 27, 2015 at 21:18
  • $\begingroup$ @ybeltukov, thank you -- somehow it did not feel right the way it is but did not bother to try to clean it. $\endgroup$
    – kglr
    Jan 27, 2015 at 23:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.