File:Mean estimator consistency.gif

Summary

Description
English: If you sample from a Cauchy distribution, the probability to get a value very far on the tails is so high that more data won't ever give you a better estimate of its mean.
Date
Source https://twitter.com/j_bertolotti/status/1303999888137613312
Author Jacopo Bertolotti
Permission
(Reusing this file)
https://twitter.com/j_bertolotti/status/1030470604418428929

Mathematica 12.1 code

n = 5 10^3;
data = RandomVariate[NormalDistribution[0, 10], n];
data2 = RandomVariate[CauchyDistribution[0, 10], n];
p0 = Table[
   GraphicsGrid[{
     {Show[
       Histogram[data[[1 ;; j]], {1}, "Probability", ChartStyle -> Orange],
       Plot[PDF[NormalDistribution[0, 10], x], {x, -40, 40}, PlotRange -> All, PlotStyle -> {Purple, Thick}]
       , PlotRange -> {{-30, 30}, {0, 0.045}}, Axes -> False, Frame -> True, FrameLabel -> {"x", "P(x)"}, LabelStyle -> {Black, Bold}, PlotLabel -> "Normal distribution"
       ]
      ,
      ListPlot[Table[Mean[data[[1 ;; i]] ], {i, 9, j}], Joined -> True, PlotRange -> {{0, n}, All}, DataRange -> j, Axes -> False, Frame -> True, FrameLabel -> {"#", "\!\(\*OverscriptBox[\(\[Mu]\), \(^\)]\)"},        LabelStyle -> {Black, Bold}, PlotStyle -> Black, Epilog -> {Purple, Thick, Dashed, Line[{{0, 0}, {n, 0}}]}]
      ,
      ListPlot[Table[StandardDeviation[data[[1 ;; i]] ], {i, 9, j}], Joined -> True, PlotRange -> {{0, n}, All}, DataRange -> j, Axes -> False, Frame -> True, FrameLabel -> {"#", "\!\(\*OverscriptBox[\(\[Sigma]\), \(^\)]\)"}, LabelStyle -> {Black, Bold}, PlotStyle -> Black, Epilog -> {Purple, Thick, Dashed, Line[{{0, 10}, {n, 10}}]}]
      }, {
      
      Show[
       Histogram[data2[[1 ;; j]], {1}, "Probability", ChartStyle -> Orange],
       Plot[PDF[CauchyDistribution[0, 10], x], {x, -40, 40}, PlotRange -> All, PlotStyle -> {Purple, Thick}], PlotRange -> {{-40, 40}, {0, 0.035}}, Axes -> False, Frame -> True, FrameLabel -> {"x", "P(x)"},        LabelStyle -> {Black, Bold}, PlotLabel -> "Cauchy distribution"]
      ,
      ListPlot[Table[Mean[data2[[1 ;; i]] ], {i, 1, j}], Joined -> True, PlotRange -> {{0, n}, All}, DataRange -> j, Axes -> False, Frame -> True, FrameLabel -> {"#", "\!\(\*OverscriptBox[\(\[Mu]\), \(^\)]\)"}, LabelStyle -> {Black, Bold}, PlotStyle -> Black, Epilog -> {Purple, Thick, Dashed, Line[{{0, 0}, {n, 0}}]}]
      ,
      ListPlot[Table[StandardDeviation[data2[[1 ;; i]] ], {i, 2, j}], Joined -> True, PlotRange -> {{0, n}, All}, DataRange -> j, Axes -> False, Frame -> True, FrameLabel -> {"#",          "\!\(\*OverscriptBox[\(\[Sigma]\), \(^\)]\)"}, LabelStyle -> {Black, Bold}, PlotStyle -> Black]
      }}, ImageSize -> 800]
   , {j, 10, n, 20}];
ListAnimate[p0]

Licensing

I, the copyright holder of this work, hereby publish it under the following license:
Creative Commons CC-Zero This file is made available under the Creative Commons CC0 1.0 Universal Public Domain Dedication.
The person who associated a work with this deed has dedicated the work to the public domain by waiving all of their rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law. You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.

Category:CC-Zero#Mean%20estimator%20consistency.gif
Category:Self-published work Category:Statistics Category:Cauchy-Lorentz distributions Category:Normal distribution Category:Images with Mathematica source code Category:Animated GIF files between 50 MP and 100 MP Category:Animated GIF files
Category:Animated GIF files Category:Animated GIF files between 50 MP and 100 MP Category:CC-Zero Category:Cauchy-Lorentz distributions Category:Images with Mathematica source code Category:Normal distribution Category:Pages using deprecated source tags Category:Self-published work Category:Statistics