A coin is tossed 10 number of times. Each toss results in one of two outcomes: head or tail. We are interested in the number of heads observed. The probability of observing each of these two outcomes is the same for all tosses.

find the following probabilities:

a) The result of all 10 tosses is heads

b) The result is exactly 2 heads from the 10 tosses

c) The result is at least 4 heads from the 10 tosses

a) We can calculate the probability using the following code:

In [30]:

```
from scipy.stats import binom
x = binom.pmf(k=10, n=10, p=0.5)
print("P(X=10)=",x)
```

P(X=10)= 0.0009765625

b) In this case again we put the proper values in code:

In [31]:

```
from scipy.stats import binom
x = binom.pmf(k=2, n=10, p=0.5)
print("P(X=2)=",x)
```

P(X=2)= 0.04394531249999999

c) In this case we are interested in all probabilities equal or greater than 4.

We use the CDF, instead of PDF:

In [32]:

```
from scipy.stats import binom
x = 1 - binom.cdf(k=3, n=10, p=0.5)
print("1-P(X≤3)=",x)
```

1-P(X≤3)= 0.828125

In factory fabric defects occur randomly at an average rate of 1.8 defects per day. What is the probability of observing:

a) 4 defects in a given day?

b) 2 or more defects in a given day?

a) We can calculate the probability using the following code:

In [33]:

```
from scipy.stats import poisson
x = poisson.pmf(k=4, mu=1.8)
print("P(X=4)=",x)
```

P(X=4)= 0.07230173370812194

b) We calculate this probability using CDF

In [34]:

```
from scipy.stats import poisson
s = 1 - poisson.cdf(k=1, mu=1.8)
print("P(X≥2)= ",s)
```

P(X≥2)= 0.5371631129795577

a) A normal distribution has mean = 50 and standard deviation = 10. What is the area between 50 and 70?

b) For a normal distribution with mean 0 and standard deviation 1, approximately what is the area between -2 and -1?

c) The average time of making jeans in an jeans factory is normally distributed with a mean time 15 minutes and standard deviation of 0.5 minutes. What is the proportion of jeans which are made between 15.6 and 16.1 minutes?

a) We can calculate the probability using the following code:

In [35]:

```
from scipy.stats import norm
x = norm.cdf(x=70, loc=50, scale=10) - norm.cdf(x=50, loc=50, scale=10)
print("P(50≤X≤70)= ",x)
```

P(50≤X≤70)= 0.4772498680518208

b) We can calculate the probability using the following code:

In [36]:

```
from scipy.stats import norm
#calculate binomial probability
x = norm.cdf(x=1) - norm.cdf(x=-2)
#Print the result
print("P(-2≤X≤1)= ",x)
```

P(-2≤X≤1)= 0.8185946141203637

c) We can calculate the probability using the following code:

In [37]:

```
from scipy.stats import norm
#calculate binomial probability
x = norm.cdf(x=16.1, loc=15, scale=0.5) - norm.cdf(x=15.6, loc=15, scale=0.5)
#Print the result
print("P(15.6≤X≤16.1)= ",x)
```

P(15.6≤X≤16.1)= 0.10116622270820996

In [ ]:

```
```