10
Chi-squared distribution 2 N N = number of degrees of freedom Computed using incomplete gamma function: Moments of 2 distribution: f ( x ) = 1 Γ ( N /2)2 N /2 x ( N / 2−1) e x /2 Γ (1)= 1 Γ (1/2)= π Γ ( n )= ( n − 1)! Γ ( α )= ( α −1) Γ ( α − 1) e . g . Γ (3/2)= (1/2) Γ (1/2)= π /2 N 2 = N σ 2 ( χ N 2 )= 2N

Chi-squared distribution 2 N N = number of degrees of freedom Computed using incomplete gamma function: Moments of 2 distribution:

Embed Size (px)

Citation preview

Page 1: Chi-squared distribution  2 N N = number of degrees of freedom Computed using incomplete gamma function: Moments of  2 distribution:

Chi-squared distribution 2N

• N = number of degrees of freedom

• Computed using incomplete gamma function:

• Moments of 2 distribution:

f (x) =1

Γ(N / 2) 2N / 2 x(N / 2−1)e−x/2

Γ (1) = 1 Γ (1/ 2) = π

Γ (n) = (n −1)! Γ (α ) = (α −1)Γ (α −1)

e.g.Γ (3 / 2) = (1/ 2)Γ (1 / 2) = π / 2

N2 = N

σ 2 (χ N2 ) = 2N

Page 2: Chi-squared distribution  2 N N = number of degrees of freedom Computed using incomplete gamma function: Moments of  2 distribution:

Constructing 2 from Gaussians - 1

• Let G(0,1) be a normally-distributed random variable with zero mean and unit variance.

• For one degree of freedom:

• This means that:

12 = G2 (0,1)

P(χ 12 < a2 ) = P( G2 (0,1) < a)

0

0.2

0.4

0.6

0.8

1

-3 -2 -1 0 1 2 3 4 5

0.0

0.2

0.4

0.6

0.8

1.0

-3 -2 -1 0 1 2 3 4 5

-a a

G(0,1)

21

a2

i.e. The 2 distribution with 1 degreeof freedom is the same as the distribution of the square of asingle normally distributed quantity.

Page 3: Chi-squared distribution  2 N N = number of degrees of freedom Computed using incomplete gamma function: Moments of  2 distribution:

Constructing 2 from Gaussians - 2

• For two degrees of freedom:

• More generally:

• Example: Target practice!

• If X1 and X2 are normally distributed:

• i.e. R2 is distributed as chi-squared with 2 d.o.f

22 = χ 1

2 + χ 12

X1

X2

X1 ~ G(0,1) and X2 ~ G(0,1)

R2 =X12 + X2

2

⇒ R2 ~ 22

N+M2 = χ N

2 + χ M2

Page 4: Chi-squared distribution  2 N N = number of degrees of freedom Computed using incomplete gamma function: Moments of  2 distribution:

Data points with no error bars

• If the individual i are not known, how do we estimate for the parent distribution?

• Sample mean:

• Variance of parent distribution:

• By analogy, define sample variance:

• Is this an unbiased estimator, i.e. is <s2>=2?

X =1N

Xii=1

N

2 (X) ≡ (X − X )2

s2 (X ) =1N

(Xi − X)2

i=1

N

Page 5: Chi-squared distribution  2 N N = number of degrees of freedom Computed using incomplete gamma function: Moments of  2 distribution:

Estimating 2 – 1

• Express sample variance as:

• Use algebra of random variables to determine:

• Expand:

s2 (X) =A (Xi − X)2

i=1

N

s2 =A (Xi − X)2

i=1

N

∑(Xi − X)2 = (Xi − X )−( X − X )[ ]

2

= (Xi − X )2 −2(Xi − X )( X − X ) + ( X − X )2

= 2 (Xi ) −2Cov(Xi , X) + 2 ( X)

= 2 −2 2

N+ 2

N

= 2 1−1N

⎛⎝⎜

⎞⎠⎟ = 2 N −1

N⎛⎝⎜

⎞⎠⎟

(Don’t worry,all will be revealed...)

Page 6: Chi-squared distribution  2 N N = number of degrees of freedom Computed using incomplete gamma function: Moments of  2 distribution:

Aside: what is Cov(Xi,X)?

Cov(Xi , X ) = (Xi − Xi )( X − X )

But note that: Xi = X = X

So shift coords to putX =0 and get:

Cov(Xi , X) = (Xi −0)( X −0)

= Xi

1N

Xkk∑ =

1N

Xi Xkk∑ =

1N

2

k∑ δ ik =

2

N

X

Xi

<X>

<Xi>

Page 7: Chi-squared distribution  2 N N = number of degrees of freedom Computed using incomplete gamma function: Moments of  2 distribution:

Estimating 2 – 2

• We now have

• For s2 to be an unbiased estimator for 2, need A=1/(N-1):

s2 =A 2 (N −1

Ni=1

N

∑ ) =A 2 (N −1)

s2 = 1N −1

(Xi − Xi=1

N

∑ )2

s2 = 2

Page 8: Chi-squared distribution  2 N N = number of degrees of freedom Computed using incomplete gamma function: Moments of  2 distribution:

<X>

Xi − X( )i=1

N

∑2

≈ N2( ) 2

Xi − X( )i=1

N

∑2

≈ N−12( ) 2

Xi − X( )i=1

N

∑2

=(N −1) 2

• If all observations Xi have similar errors :

• If we don’t know <X> use X instead:

• In this case we have N-1 degrees of freedom. Recall that:

• (since <2N>=N)

Degrees of freedom – 1

Page 9: Chi-squared distribution  2 N N = number of degrees of freedom Computed using incomplete gamma function: Moments of  2 distribution:

Degrees of freedom – 2

• Suppose we have just one data point. In this case N=1 and so:

• Generalising, if we fit N data points with a function A involving M parameters 1... M:

• The number of degrees of freedom is N-M.

Xi =X

Xi − X( )2 =σ 2

Xi −X ( )2 =0 – zero degrees of freedom!

Xi −A( v)( )

i=1

N

∑2

≈ N−M2( ) 2

Page 10: Chi-squared distribution  2 N N = number of degrees of freedom Computed using incomplete gamma function: Moments of  2 distribution:

Example: bias on CCD frames

obs2 =

Xi − X ( )2

s2i=1

N

• Suppose you want to know whether the zero-exposure (bias) signal of a CCD is uniform over the whole image.

• First step: determine s2(X) over a few sub-regions of the frame.

• Second step: determine X over the whole frame.

• Third step: Compute

• In this case we have fitted a function with one parameter (i.e. the constant X), so M=1 and we expect < 2 > = N - 1

• Use 2N - 1 distribution to determine probability

that 2> 2obs