# Statistics

## Statistics

variance and standard deviation = dispersion (集中 or 分散)

expected value = 長期平均獲利

covariance = two variables have same changes or not

|                    | Example One                       | Example Two                    |
| ------------------ | --------------------------------- | ------------------------------ |
|                    | -10, 0, 10, 20, 30                | 8, 9, 10, 11, 12               |
| mean (average)     | (-10 + 0 + 10 + 20 + 30) / 5 = 10 | (8 + 9 + 10 + 11 + 12) / 5 =10 |
| variance           | 200                               | 2                              |
| standard deviation | 141                               | 1.41                           |

![](https://3261671725-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lq83PzGfjVutWtDeb3l%2F-Lq83T8WxyHGIG5BRnUx%2F-Lq83TX8TDhV_8GECs0P%2Fstd_formula.png?generation=1569962716339802\&alt=media)

### Expected value

1. the long-run average value of the **same experiment**
2. Whole population mean

```
E(x) = sum(probability * x_value)
```

打擊率0.35的選手打100球, 期望打到35球

### Convairance

1. stock A & stock B move at the same direction -> positive covariance
2. stock A & stock B move at the opposite direction -> negative covariance
3. Covariance =(1) how far the variables are spread out (2) the nature of their relationship
4. degree to which two variables are linearly associated.
5. Two are independent will have covariance = 0

Correlation is a scaled version of covariance that takes on values in \[−1,1]

![](https://3261671725-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lq83PzGfjVutWtDeb3l%2F-Lq83T8WxyHGIG5BRnUx%2F-Lq83TXDIROir8eT3EDb%2Fcov_1.png?generation=1569962716658406\&alt=media)![](https://3261671725-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lq83PzGfjVutWtDeb3l%2F-Lq83T8WxyHGIG5BRnUx%2F-Lq83TXF3Ff26HnBGLGj%2Fcov_2.png?generation=1569962716437241\&alt=media)

## Binomial / Bernoulli / Poisson

### Binomial Distribution

1. discrete probability distribution.
2. Outcome is True or False. (Dice shows 4, or not 4)

![](https://3261671725-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lq83PzGfjVutWtDeb3l%2F-Lq83T8WxyHGIG5BRnUx%2F-Lq83TXH0cuFvAIWgiYN%2Fbinomial.png?generation=1569962716494424\&alt=media)

### Bernoulli distribution

1. two possible outcome
2. For a single trial, i.e., n = 1, the binomial distribution is a Bernoulli distribution.

![](https://3261671725-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lq83PzGfjVutWtDeb3l%2F-Lq83T8WxyHGIG5BRnUx%2F-Lq83TXJYzOodQw7jBO2%2Fbernoulli_1.png?generation=1569962716539267\&alt=media)

![](https://3261671725-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lq83PzGfjVutWtDeb3l%2F-Lq83T8WxyHGIG5BRnUx%2F-Lq83TXLBpm3hRWG85Gp%2Fbernoulli_2.png?generation=1569962716430074\&alt=media)

![](https://3261671725-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lq83PzGfjVutWtDeb3l%2F-Lq83T8WxyHGIG5BRnUx%2F-Lq83TXNrICgJCNMkp6Q%2Fbernoulli_3.png?generation=1569962716385990\&alt=media)

### Poisson process

1. we know the average time between events but they are randomly spaced (stochastic)
2. Earthquake happens every 5 years in A-zone, but we don't know when is next.
3. the binomial distribution with large trials(continuous) and rare happens = poisson

![](https://3261671725-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lq83PzGfjVutWtDeb3l%2F-Lq83T8WxyHGIG5BRnUx%2F-Lq83TXPBaip6BTeQlLs%2Fpoisson_1.png?generation=1569962716361225\&alt=media)

lambda = expected number of events in the interval

**Meteor example**

![](https://3261671725-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lq83PzGfjVutWtDeb3l%2F-Lq83T8WxyHGIG5BRnUx%2F-Lq83TXR5giQGIGCiv1Y%2Fpoisson_3.png?generation=1569962724829654\&alt=media)

![](https://3261671725-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lq83PzGfjVutWtDeb3l%2F-Lq83T8WxyHGIG5BRnUx%2F-Lq83TXT07WLSP6G31hV%2Fpoisson_4.png?generation=1569962716484060\&alt=media)

![](https://3261671725-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lq83PzGfjVutWtDeb3l%2F-Lq83T8WxyHGIG5BRnUx%2F-Lq83TXVIZAOmbPv4CKy%2Fpoisson_5.png?generation=1569962724598536\&alt=media)

#### Waiting time

the probability of waiting less than or equal to a time:

![](https://3261671725-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lq83PzGfjVutWtDeb3l%2F-Lq83T8WxyHGIG5BRnUx%2F-Lq83TXXdJpokmQYR8VE%2Fpoisson_7.png?generation=1569962716359807\&alt=media)

wait for 6mins, you will have 39% chance to see a meteor.

1 - math.exp((1/12)\*6) = 39%

<https://towardsdatascience.com/the-poisson-distribution-and-poisson-process-explained-4e2cb17d459>
