I am learning Mathematica on the fly, one of my tasks is to find the variance of white noise. I followed the tutorial for finding white noise by using the code:

WN = WhiteNoiseProcess[NormalDistribution[0, 10]];

data = RandomFunction[WN, {0, 10000}];

I know I can use the following code to find the variance:Variance[data]

However, I would like to find it by using the formula for variance. I checked the reference built into Mathematica and it says I can simply use:

Total[(list-Mean[list])^2]/(Length[list]-1)

I input data for the list:

Total[(data-Mean[data])^2]/(Length[data]-1)

When I do this, I don’t get the same output as when I use the Variance[data] code, but instead get:

So, I am curious what I am doing wrong? I’m sure it’s something simple I am not doing, but after spending a couple of hours wrestling with this, I am breaking down to ask. Sorry if this is a dumb question. Thank you in advance for your time.

=================

Welcome to Mathematica.SE! I suggest that: 1) You take the introductory Tour now! 2) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! 3) As you receive help, try to give it too, by answering questions in your area of expertise.

– bbgodfrey

May 15 ’15 at 22:24

You must extract the values (path) – see the doc for details under properties of temporaldata…

– ciao

May 15 ’15 at 22:31

2

I did some digging in there and used: Total[(data[“Values”] – Mean[data[“Values”]])^2]/(Length[ data[“Values”]] – 1) This resolved the same as the Variance expression.

– Sean Alto

May 15 ’15 at 22:39

=================

2 Answers

2

=================

The specific approach is as follows. Convert data to an ordinary list, eliminate an extra set of {}, and insert the list into your formula:

dta = First@Normal@data;

Last@Total[(dta – Last@Mean[dta])^2]/(Length[dta] – 1)

which gives the same result as

Variance[data]

namely 102.245 for the particular set of random numbers used.

Outstanding, I was positive it was something small I was missing. Thank you for your help.

– Sean Alto

May 15 ’15 at 22:41

It is valuable to look at the properties of these complex objects, e.g. in your example:

data[“Properties”]

To do your own variance:

val = First@data[“ValueList”];

Variance[val]

Total[(val – Mean[val])^2]/(Length[val] – 1)

You can compare results of Variance and your mimic.