October 10, 2013---Class 14---Jackknife Error, Jackknife Method
Via Mathematica, Introduction to Chaos and Logistic Map
Activities:
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.
For the mean, we looked at the distribution of values and distibution
of the jackknife samples. The dispersion of the latter is very small.
This verifies why we need the factor n in the numerator for the
jackknife error.
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.
You may consult the Mathematica notebook feb27_jackknife.nb to
follow some of the calculations done in class.
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) .
A program ~sg/map.c allows you to follow the time history of a
population. Map takes three command line arguments: r, the
parameter that appears above in the definition of the map; x_0, the
initial value of the population; and iterations, the total number
of generations to calculate. The executable is ~sg/bin/map.
We saw what happens after a long time if we use r=0.1.
The population dies out if we start with x=0.1
map 0.1 0.1 100
A shell script was written to see what happens with different values
of x_0.
Students were asked to try different starting values. With different
values of r, the long time behavior varied. In the next class, we
will explore the behavior more systematically.