Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Maximilian Vitz
Lecture Statistics and Data Analysis
Commits
c5ba8877
Commit
c5ba8877
authored
Oct 28, 2021
by
Maximilian Vitz
Browse files
Added Solution2!
parent
dfd9db9d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Week2/Solution2.ipynb
0 → 100644
View file @
c5ba8877
%% Cell type:markdown id: tags:
### 1 Exspectation Value and Variance of a Sample
%% Cell type:markdown id: tags:
1)
%% Cell type:markdown id: tags:
See lecture slide 46.
%% Cell type:markdown id: tags:
2)
%% Cell type:markdown id: tags:
$
\l
eft
<
V
(
x
)
\
right
>
=
\l
eft
<
\
frac
{1}{
N
}
\
sum_
{
i
}
(
x_
{
i
}
-
\
mu_
{
x
})^{2}
\
right
>
=
\f
rac{1}{N}
\l
eft
<
\
sum_
{
i
}
x_
{
i
}^{2}
-
2
x_
{
i
}
\
mu_
{
x
}
+
\
mu_
{
x
}^{2}
\
right
>
=
\f
rac{1}{N}
\l
eft(
\s
um_{i}
\l
eft
<
x_
{
i
}^{2}
\
right
>
- 2
\l
eft
<
x_
{
i
}
\
right
>
\m
u_{x}
\r
ight) +
\m
u_{x}^{2} =
\l
eft
<
x
^{2}
\
right
>
- 2
\m
u_{x}^{2} +
\m
u_{x}^{2} =
\l
eft
<
x
^{2}
\
right
>
-
\l
eft
<
x
\
right
>
^{2} =
\s
igma_{x}^{2}$
%% Cell type:markdown id: tags:
By fixing a parameter for the measured mean like it was done in 1) one has to apply a correction factor. If the true mean is known this is not neccessary any more.
%% Cell type:markdown id: tags:
### 2 Poisson Distribution
%% Cell type:markdown id: tags:
$P_{k} (T) =
\f
rac{1}{k!} e^{-
\l
ambda T} (
\l
ambda T)^{k}$
%% Cell type:markdown id: tags:
(lhs) $
\d
ot{P}_{k}(T) =
\f
rac{1}{k!} e^{-
\l
ambda T} (-
\l
ambda (
\l
ambda T)^{k} + k
\l
ambda^{k} T^{k-1} )$
%% Cell type:markdown id: tags:
(rhs) $
\l
ambda [P_{k-1}(T) - P_{k}(T)] =
\l
ambda
\l
eft[
\f
rac{e^{-
\l
ambda T}}{(k-1)!} (
\l
ambda T)^{k-1} -
\f
rac{e^{-
\l
ambda T}}{k!} (
\l
ambda T)^{k}
\r
ight] =
\f
rac{1}{k!} e^{-
\l
ambda T} (-
\l
ambda (
\l
ambda T)^{k} + k
\l
ambda^{k} T^{k-1} )$
%% Cell type:markdown id: tags:
$
\R
ightarrow
\d
ot{P}_{k}(T) =
\l
ambda [P_{k-1}(T) - P_{k}(T)]$
%% Cell type:markdown id: tags:
Differential Equation was derived by comparing small time intervall with a Taylor expansion, see lecture slide 62.
%% Cell type:markdown id: tags:
### 3 Bionomial- and Poisson Distribution
%% Cell type:markdown id: tags:
1)
%% Cell type:markdown id: tags:
Bionomial Distribtion for probobility for success with N trials!
%% Cell type:markdown id: tags:
$B(k; N, p) =
\l
eft(
\b
egin{array}{c}
N
\\
k
\e
nd{array}
\r
ight)
\c
dot p^{k}
\c
dot (1-p)^{N-k}$
%% Cell type:markdown id: tags:
N = 60
%% Cell type:markdown id: tags:
p = 0.01
%% Cell type:markdown id: tags:
k = 0
%% Cell type:markdown id: tags:
$
\R
ightarrow B(0; 60, 0.01) =
\l
eft(
\b
egin{array}{c}
60
\\
0
\e
nd{array}
\r
ight)
\c
dot 0.01^{0}
\c
dot (1-0.01)^{60-0} = 1
\c
dot 1
\c
dot (0.99)^{60} = 54.7
\%
$
%% Cell type:markdown id: tags:
2)
%% Cell type:markdown id: tags:
Poisson Distribution for event which occur with an average event rate $
\l
ambda$.
%% Cell type:markdown id: tags:
$P(k,
\l
ambda) =
\f
rac{
\l
ambda^{k}}{k!} e^{-
\l
ambda}$
%% Cell type:markdown id: tags:
$
\l
ambda$ = $0.01
\c
dot 60 = 0.6$
%% Cell type:markdown id: tags:
k = 0
%% Cell type:markdown id: tags:
$P(0,0.6) =
\f
rac{0.6^{0}}{0!} e^{- 0.6} = 1
\c
dot e^{-0.6} = 54.9
\%
$
%% Cell type:markdown id: tags:
### 4 Poisson Distribution, Search for free Quarks
%% Cell type:markdown id: tags:
1)
%% Cell type:markdown id: tags:
$
\s
um_{i=1}^{110} P(i;229) =
\s
um_{i=1}^{110}
\f
rac{229^{i}}{i!} e^{-229}= 1.6
\c
dot 10^{-18} = p_{se}$
%% Cell type:markdown id: tags:
Very low propability, very unlikely to happen!
%% Cell type:markdown id: tags:
2)
%% Cell type:markdown id: tags:
N = 55000
%% Cell type:markdown id: tags:
$p_{me} = N
\c
dot p_{se} = 8.9
\c
dot 10^{-14}$
%% Cell type:markdown id: tags:
3)
%% Cell type:markdown id: tags:
$
\s
um_{i=1}^{28} P(i;57) =
\s
um_{i=1}^{28}
\f
rac{57^{i}}{i!} e^{-57}= 6.7
\c
dot 10^{-6}$
%% Cell type:markdown id: tags:
Much more likely to happend!
%% Cell type:markdown id: tags:
4)
%% Cell type:markdown id: tags:
Combine both Poisson Distributions to achieve the new probability:
%% Cell type:markdown id: tags:
$
\m
u = 4$
%% Cell type:markdown id: tags:
$
\m
u
\l
ambda = 229$
%% Cell type:markdown id: tags:
$
\s
um_{i=1}^{110}
\s
um_{N=0}^{
\i
nfty} P(i;N
\m
u)
\c
dot P(N;
\l
ambda) =
\s
um_{i=1}^{110}
\s
um_{N=0}^{
\i
nfty}
\f
rac{N
\m
u^{i}}{i!} e^{-N
\m
u}
\c
dot
\f
rac{
\l
ambda^{N}}{N!} e^{-
\l
ambda} = 4.2
\c
dot 10^{-5}$
%% Cell type:markdown id: tags:
Even more likely to happen.
%% Cell type:markdown id: tags:
### 5 Why are soccer results more random than handball results?
%% Cell type:markdown id: tags:
1)
%% Cell type:markdown id: tags:
$
\l
ambda_{1} = 1$
%% Cell type:markdown id: tags:
$
\l
ambda_{2} = 2$
%% Cell type:markdown id: tags:
$
\s
um_{i=1}^{
\i
nfty}
\s
um_{l=0}^{k-1} P(k;
\l
ambda_{1})
\c
dot P(l;
\l
ambda_{2})=
\s
um_{i=1}^{
\i
nfty}
\s
um_{l=0}^{k-1}
\f
rac{
\l
ambda_{2}^{k}}{k!} e^{-
\l
ambda_{1}}
\c
dot
\f
rac{
\l
ambda_{2}^{l}}{l!} e^{-
\l
ambda_{2}} = 18.3
\%
$
%% Cell type:markdown id: tags:
2)
%% Cell type:markdown id: tags:
$
\l
ambda_{1} = 10$
%% Cell type:markdown id: tags:
$
\l
ambda_{2} = 20$
%% Cell type:markdown id: tags:
$
\s
um_{i=1}^{
\i
nfty}
\s
um_{l=0}^{k-1} P(k;
\l
ambda_{1})
\c
dot P(l;
\l
ambda_{2})= 2.6
\%
$
%% Cell type:markdown id: tags:
Summing up over all possible combinations, i=1 as at least one goal is needed to win a game.
%% Cell type:markdown id: tags:
### 5 Python Script (thanks to Joep Geuskens)
%% Cell type:code id: tags:
```
python
from
scipy.stats
import
poisson
import
numpy
as
np
```
%% Cell type:code id: tags:
```
python
def
func
(
l
=
1
):
arr
=
np
.
array
([
poisson
.
cdf
(
k
-
1
,
2
*
l
)
*
poisson
.
pmf
(
k
,
l
)
for
k
in
range
(
1
,
l
*
10
)])
p
=
np
.
sum
(
arr
)
diff
=
arr
[
-
1
]
/
p
# relative size of the last term compared to the total probability
print
(
f
"P(B>A)=
{
p
:.
4
f
}
"
)
print
(
f
"Diff=
{
diff
:.
2
g
}
"
)
# should be sufficiently small
```
%% Cell type:code id: tags:
```
python
print
(
"1)"
)
func
(
1
)
print
(
"
\n
2)"
)
func
(
10
)
```
%%%% Output: stream
1)
P(B>A)=0.1826
Diff=5.6e-06
2)
P(B>A)=0.0258
Diff=1.9e-60
%% Cell type:markdown id: tags:
### 6 Multidimensional Gaussian
%% Cell type:markdown id: tags:
$B =
\f
rac{1}{
\s
igma_{1}^{2}
\s
igma_{2}^{2}-
\r
ho^{2}
\s
igma_{1}^{2}
\s
igma_{2}^{2}}
\l
eft(
\b
egin{array}{cc}
\s
igma_{2}^{2} & -c
\\
-c &
\s
igma_{1}^{2}
\e
nd{array}
\r
ight) =
\f
rac{1}{
\s
igma_{1}^{2}
\s
igma_{2}^{2}
\c
dot (1-
\r
ho^{2})}
\l
eft(
\b
egin{array}{cc}
\s
igma_{2}^{2} & -c
\\
-c &
\s
igma_{1}^{2}
\e
nd{array}
\r
ight)$
%% Cell type:markdown id: tags:
$c =
\r
ho x_{1} x_{2}$
%% Cell type:markdown id: tags:
$det B =
\f
rac{1}{
\s
igma_{1}^{2}
\s
igma_{2}^{2}
\c
dot (1-
\r
ho^{2})}$
%% Cell type:markdown id: tags:
$k =
\s
qrt{
\f
rac{det B}{(2
\p
i)^{n}}} =
\f
rac{1}{2
\p
i
\c
dot
\s
igma_{1}
\s
igma_{2}
\c
dot
\s
qrt{(1-
\r
ho^{2})}}$
%% Cell type:markdown id: tags:
$$
\l
eft(
\b
egin{array}{c}
x_{1}
\\
x_{2}
\e
nd{array}
\r
ight)
\l
eft(
\b
egin{array}{cc}
\s
igma_{2}^{2} & -c
\\
-c &
\s
igma_{1}^{2}
\e
nd{array}
\r
ight)
\l
eft(
\b
egin{array}{cc}
x_{1} & x_{2}
\\
\e
nd{array}
\r
ight) = x_{1}^{2}
\s
igma_{2}^{2} - 2 x_{1} x_{2} c + x_{2}^{2}
\s
igma_{1}^{2} =
\s
igma_{1}^{2}
\s
igma_{2}^{2}
\l
eft(
\f
rac{x_{1}^2}{
\s
igma_{1}^{2}} +
\f
rac{x_{2}^2}{
\s
igma_{2}^{2}} - 2
\r
ho
\f
rac{x_{1}x_{2}}{
\s
igma_{1}
\s
igma_{2}}
\r
ight)
$$
%% Cell type:markdown id: tags:
$
\P
hi (x_{1}, x_{2}) =
\f
rac{1}{2
\p
i
\c
dot
\s
igma_{1}
\s
igma_{2}
\c
dot
\s
qrt{(1-
\r
ho^{2})}}
\e
xp
\l
eft( -
\f
rac{1}{2
\c
dot (1-
\r
ho^{2})}
\l
eft(
\f
rac{x_{1}^2}{
\s
igma_{1}^{2}} +
\f
rac{x_{2}^2}{
\s
igma_{2}^{2}} - 2
\r
ho
\f
rac{x_{1}x_{2}}{
\s
igma_{1}
\s
igma_{2}}
\r
ight)
\r
ight)$
%% Cell type:markdown id: tags:
Substitue $x_{i}$ with $x_{i}- a_{i}$ to achieve the exspected form.
%% Cell type:code id: tags:
```
python
```
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment