October 16, 2007---Class 14---Jackknife Error, Jackknife Method Via Mathematica,
Introduction to Chaos and Logistic Map
Activities:
Hist
We reviewed the options to hist.
Jackknife Error
In addition to using the jackknife method for bias reduction, you
can use it to calculate the sample error. The sample error is
related to variance of the jackknife samples. Because these
samples are so correlated (only one variable changes in each
sample), the variance of the jackknife values must be multiplied by
(n-1):
(\sigma_J)^2 = (n-1)/n \sum (S'_i - S)^2
where S'_i is the jackknife statistic with the i'th measurement
removed and S is the statistic on the entire set of n measurements.
Notice that in the simple case that the statistic is the mean value
of the sample, the naive variance would be given by:
\sigma^2 = 1/[n(n-1)] \sum (x_i - x_avg)^2
In this case, it is easy to show S'_i - S = (x_avg - x_i)/(n-1).
Here is a deriviation:
(n-1) S'_i + x_i = sum of all x_i = n(S) = n x_avg = (n-1)S + x_avg
since S and x_avg are the same in this example. Bring the terms
involving S to the left, the terms involving x to the right and
divide by (n-1) to complete the derivation.
Jackknife Method Via Mathematica
Mathematica can be used to generate samples of random numbers and
to apply the jackknife technique. This is a good opportunity to
introduce a new mathematica construct the "module", which is like
a subroutine. In ~sg/jackknife/jackn.math is the code to implement
this method.
First we need a way to create our set of random variables. This is
done via the newvars command:
newvars[num_] := Do[z[i] = Random[], {i, num}]
Once this is defined, you may create as many new random numbers
in the vector z by calling newvars with the number you desire
as the argument.
A Module in mathematica takes two arguments. The first is a list
of variables local to the module, and the second is an expression,
i.e., a sequence of statements.
Using a module statement we define jackknife[x_, num_Integer],
where x is vector of random numbers and num is the sample size.
Here is the code:
jackknife[x_, num_Integer] :=
Module[{mysum, mysumpr, stat, statpr, estimate, fctr, i},
fctr = N[(num - 1)/num]; mysum = Sum[x[i], {i, 1, num}];
stat = num/mysum; estimate = num*stat;
Do[mysumpr = mysum - x[i]; statpr = (num - 1)/mysumpr;
estimate -= fctr*statpr, {i, 1, num}]; {stat, estimate}]
Successive calls to newvars and jackknife are equivalent to what
was done in the C code in the last class. I made a table from many
calls of newvars and jackknife, from which a scatterplot was
produced using ListPlot.
Chaos and the Logistic Map
We introduced the logistic map from
consideration of an insect population model.
P_{n+1} = P_n (A - B P_n)
Upon scaling the population, the population is
replaced by x which lies in the range [0,1]. The next generation
is given by
x <- 4 r x * (1-x) .