A random variable is a numerical description of the outcome of a statistical experiment. A random variable that may assume only a finite number or an infinite sequence of values is said to be discrete; one that may assume any value in some interval on the real number line is said to be continuous.

# Expected value

The expected value for a variable X is the value of X we would **expect** to get after performing the experiment once. ***It is also called the expectation, average, and mean value***. Mathematically speaking, for a random variable X that can take values x<sub>1</sub>,x<sub>2</sub>,x<sub>3</sub>,...........,x<sub>n</sub>, the expected value (EV) is given by:

\begin{align}
EV(X) = {x_1*P(X=x_1)+x_2*P(X=x_2)+x_3*P(X=x_3)+......+x_n*P(X=x_n)}
\end{align}



Sample question:

Hugo is considering buying a scratch-off lottery ticket that costs 3 dollars. If the ticket wins, he can redeem the ticket for 50 dollars. If the ticket loses, the ticket is worthless. According to the lottery's website, 2%, percent of all tickets are winners.

Find the expected value of buying a scratch-off lottery ticket. 

1. There is a 2%, percent chance of the ticket winning. If this happens, the value is 50−3=47 (the redemption value minus the cost of the ticket).
2. There is a 98%, percent chance of the ticket losing. In this case, the value is −3 (just the cost of the ticket).
3. Let's multiply each value by its probability because expected value is the sum of all possible values, each value multiplied by its probability.
   
| Type           | Value | Probability | Value.Probability |
| -------------- | ----- | ----------- | ----------------- |
| Winning ticket | 47    | 0.020       | .94               |
| Losing ticket  | −3    | 0.980       | −2.94             |

The expected value is 0.94+(−2.94)=−2

# Binomial Probability

The formula for finding binomial probability is given by -

 
\begin{align}
P(X=r) = {C^n_r \cdot p^r(1-p)^{n-r}}
\end{align}

Sample question:

Steph's little brother Luke only has a 20%, percent chance of making a free-throw. He is going to shoot 4444 free-throws.
What is the probability that he makes exactly 2 of the 4 free throws?

1. n=4, equals, 4 trials (shots)
2. each shot is either a make or miss
3. probability that he makes a shot is p=0.20
4. shots are independent

P(exactly 2 makes) =<sup>4</sup>C<sub>2</sub>*(0.20)<sup>2</sup>*(0.80)<sup>2</sup>
```
= (4−2)!/2!*4!*0.04*0.64

= (4*3*2*1/(2*2))*0.04*0.64

= 6*0.04*0.64

= 0.1536
```

# Cumulative probability

A cumulative probability refers to the probability that the value of a random variable falls within a specified range. Frequently, cumulative probabilities refer to the probability that a random variable is less than or equal to a specified value.
Cumulative probability of X, denoted by F(x), is defined as the probability of the variable being less than or equal to x.

 Consider a coin flip experiment. If we flip a coin two times, we might ask: What is the probability that the coin flips would result in one or fewer heads? The answer would be a cumulative probability. It would be the probability that the coin flip results in zero heads plus the probability that the coin flip results in one head. Thus, the cumulative probability would equal:

P(X < 1) = P(X = 0) + P(X = 1) = 0.25 + 0.50 = 0.75 

| Number of heads | Probability | Cumulative Probability |
| --------------- | ----------- | ---------------------- |
| 0               | 0.25        | 0.25                   |
| 1               | 0.50        | 0.75                   |
| 2               | 0.25        | 1.00                   |

A CDF, or a cumulative distribution function, is a distribution which plots the cumulative probability of X against X.

A PDF, or Probability Density Function, however, is a function in which the area under the curve, gives you the cumulative probability.

The main difference between the cumulative probability distribution of a continuous random variable and a discrete one, is the way we plot them. While the continuous variables’ cumulative distribution is a curve, the distribution for discrete variables looks more like a bar chart.

A commonly observed type of distribution among continuous variables is the uniform distribution. For a continuous random variable following a uniform distribution, the value of probability density is equal for all possible values.

PDFs are more commonly used in real life. The reason is that it is much easier to see patterns in PDFs as compared to CDFs. For example, here are the PDF and the CDF of a uniformly distributed continuous random variable.



The PDF clearly shows uniformity, as the probability density’s value remains constant for all possible values. However, the CDF does not show any trends that help you identify quickly that the variable is uniformly distributed.




it is clear that the symmetrical nature of the variable is much more apparent in the PDF than in the CDF.

# Normal Distribution

All data that is normally distributed follows the **1-2-3** rule. This rule states that there is:

1. 68% probability of the variable lying within 1 standard deviation of the mean

2. 95% probability of the variable lying within 2 standard deviations of the mean

3. 99.7% probability of the variable lying within 3 standard deviations of the mean





***Standardised random variable (Z-Score)*** tells us how many standard deviations away from the mean the random variable is.

\begin{align}
Z = {X - \mu \over \sigma}
\end{align}

Cumulative probability from Z-Score is calculated using Z Table.

If we need to find the cumulative probability for Z = 0.68




The intersection of row **0.6** and column **0.08**, i.e. **0.7517**, is the answer.

# Central Limit Theorem




So, there are two important properties for a sampling distribution of the mean:

1. Sampling distribution’s mean (μ<sub>X̄</sub>) = Population mean (μ)

2. Sampling distribution’s standard deviation (Standard error) = σ/√n, where σ is the population’s standard deviation and n is the sample size


### The central limit theorem says that, for any kind of data, provided a high number of samples has been taken, the following properties hold true:

1. Sampling distribution’s mean (μ<sub>X̄</sub>) = Population mean (μ)

2. Sampling distribution’s standard deviation (Standard error) = σ/√n

3. For n > 30, the sampling distribution becomes a normal distribution

## Confidence Interval

\begin{align}
Confidence Interval = {(X-\frac {Z^*S}{\sqrt(n)},X+\frac {Z^*S}{\sqrt(n)})}
\end{align}


\begin{align}
Margin of error = {\frac {Z^*S}{\sqrt(n)}}
\end{align}



#### Z<sup>*</sup> is the Z-score associated

Some commonly used Z<sup>*</sup> values are:


| Confidence Level| Z* |
| --------------- | ----------- | 
| 90%              | ±1.65        | 
| 95%             | ±1.96       | 
| 99%             | ±2.58        | 




```python

```

9297d93fdbe4f192a7545bd96cb2a90479f90ca8
ipynb
Jupyter Notebook
Statistics Essential /inferential_statistics.ipynb
ashwanikumar04/ml-ai-notes
f6164230db555cdb4606b55f787aa1e4cb099bf2
MIT
Statistics Essential /inferential_statistics.ipynb
ashwanikumar04/ml-ai-notes
f6164230db555cdb4606b55f787aa1e4cb099bf2
MIT
Statistics Essential /inferential_statistics.ipynb
ashwanikumar04/ml-ai-notes
f6164230db555cdb4606b55f787aa1e4cb099bf2
MIT
Qwen/Qwen-72B
1. YES
2. YES