Re: Re: Unexpected Characters Appearing in
- To: mathgroup at smc.vnet.net
- Subject: [mg103308] Re: [mg103291] Re: [mg103263] Unexpected Characters Appearing in
- From: Gregory Lypny <gregory.lypny at videotron.ca>
- Date: Mon, 14 Sep 2009 07:12:18 -0400 (EDT)
- References: <20090913102455.L99QL.153756.imail@eastrmwml38>
Guess it's something to do with my machine or my version of Mathematica (7.0.1). I may delete Mathematica's preference file. Maybe it's corrupt. Gregory On 2009-09-13, at 10:24 AM, Bob Hanlon wrote: > > I don't see any exclamation marks in the output > > $Version > > 7.0 for Mac OS X x86 (64-bit) (February 19, 2009) > > stdDev[x_] := > Sqrt[Plus @@ (Plus[#, -Mean@x]^2 & /@ x)/Length@x] > > What you are calling the standard deviation is a biased estimator of > the standard deviation of the total population (from which your > sample is drawn). This estimate is the root mean square of the > deviation from the mean. > > data = {a, b, c, d, e}; > > stdDev[data] == > RootMeanSquare[data - Mean[data]] == > > Sqrt[Total[(data - Mean[data])^2]/Length[data]] > > True > > The unbiased estimator of the standard deviation of the population > is StandardDeviation > > StandardDeviation[data] == > > Sqrt[Total[(data - Mean[data])^2]/(Length[data] - 1)] // > > Simplify[#, Element[data, Reals]] & > > True > > p = {{107, 138}, {119, 129}, > {104, 101}, {107, 91}, {123, 94}}; > > StandardDeviation /@ Transpose[p] // N > > {8.42615,21.4546} > > stdDev /@ Transpose[p] // N > > {7.53658,19.1896} > > Note that the biased estimate under-estimates the standard deviation > > r = Differences@p/Most@p; > > StandardDeviation /@ Transpose[r] // N > > {0.122332,0.103158} > > stdDev /@ Transpose[r] // N > > {0.105942,0.0893377} > > > Bob Hanlon > > ---- Gregory Lypny <gregory.lypny at videotron.ca> wrote: > > ============= > Hi Bobby, > > Yeh, you're right. Kind of skimped on the details. Sorry about that. > > Here's some data, five observations each on the prices of two stocks. > First element in each is stock 1 and the second element is stock 2. > > p= {{107, 138}, {119, 129}, {104, 101}, {107, 91}, {123, 94}} > > Here's a function for computing standard deviation that goes down each > "column" as it were. I think a version of this was suggested on > MathGroup. > > stdDev[x_] := Sqrt[Plus @@ (Plus[#, -Mean@x]^2 & /@ x)/Length@x] > > The standard deviation of price is not a problem. > > {7.53658, 19.1896} > > Now I convert the prices to returns, > > (r = Differences@p/Most@p) > > {{12/107, -(3/46)}, {-(15/119), -(28/129)}, {3/104, -(10/101)}, > {16/107, 3/91}} > > leaving me with four observations each because of the differencing. > Taking the standard deviation of returns gives me > > {0.105942 \.10, 0.0893377 \.10} > > where the \.10 appears when I copy from Mathematica and paste into my > mail software, but in Mathematica, the \.10 appears as an exclamation > mark (!) with what appears to be a skinny space between it and the > last digit reported for each result. > > The answers for returns are correct, and the exclamation mark still > appears if I compute r as a numerical approximation rather than > rationals. Any thoughts? > > Regards, > > Gregory > > > > On 2009-09-12, at 1:47 AM, DrMajorBob wrote: > >> Details, Gregory. Details. >> >> Bobby >> >> On Fri, 11 Sep 2009 18:57:30 -0500, Gregory Lypny <gregory.lypny at videotron.ca >>> wrote: >> >>> Hello everyone, >>> >>> I created a function to compute standard deviation, and in some >>> instances it returns a result with an exclamation mark (!) at the >>> end, >>> as in >>> >>> 0.143855 ! >>> >>> When the result is copied as plain text and pasted elsewhere, it >>> comes >>> out as >>> >>> 0.143855 \.10 >>> >>> Any reason why this is happening? I recently upgraded my Mac to >>> Snow >>> Leopard, and thought that might be the cause. >>> >>> Regards, >>> >>> Gregory >>> >> >> >> -- >> DrMajorBob at yahoo.com >