Assignment Mridul
Assignment Mridul
Mridul Sarmah
01-10-2024
6.(b) Solution
In [ ]: import numpy as np
import matplotlib.pyplot as plt
# Step 1: Generate 1000 random samples using the inverse CDF method
n = 1000
u = np.random.uniform(0, 1, n)
x = np.sqrt(u) # Apply the inverse CDF: X = sqrt(U)
# Parameters
P = 0.48 # True population proportion
n = 1500 # Sample size
num_samples = 100 # Number of samples
confidence_level = 0.98 # 98% confidence level
Z = 2.326 # Z-value for 98% confidence level
# Plotting the confidence intervals and sample proportions with flipped axes
plt.figure(figsize=(10, 8))
for i, (ci_lower, ci_upper) in enumerate(intervals):
if contains_P[i]:
plt.plot([ci_lower, ci_upper], [i, i], color='blue') # Interval contain
else:
plt.plot([ci_lower, ci_upper], [i, i], color='red') # Interval doesn't
# Parameters
n_samples = 25 # Number of independent samples in each trial
num_trials = 1000 # Number of trials
a, b = 0, 1 # Uniform distribution range [0, 1]
# Step 4: Plot the normal distribution with same mean and std
x = np.linspace(min(sums), max(sums), 100)
plt.plot(x, norm.pdf(x, mean_s25, std_s25), 'r', lw=2, label=f'Normal Density\nM
# Parameters
n_samples = 25 # Number of independent samples in each trial
num_trials = 1000 # Number of trials
# Step 5: Plot the normal distribution with the same mean and standard deviation
x = np.linspace(min(sums), max(sums), 100)
plt.plot(x, norm.pdf(x, mean_s25, std_s25), 'r', lw=2, label=f'Normal Density\nM
# Parameters
n_samples = 25 # Number of independent samples in each trial
num_trials = 1000 # Number of trials
# Step 5: Plot the normal distribution with the same mean and standard deviation
x = np.linspace(min(sums), max(sums), 100)
plt.plot(x, norm.pdf(x, mean_s25, std_s25), 'r', lw=2, label=f'Normal Density\nM
# Parameters
n_samples = 25 # Number of independent samples in each trial
num_trials = 1000 # Number of trials
# Step 5: Plot the normal distribution with the same mean and standard deviation
x = np.linspace(min(sums), max(sums), 100)
plt.plot(x, norm.pdf(x, mean_s25, std_s25), 'r', lw=2, label=f'Normal Density\nM
Po.8
Ho
Since Aize
C>30)
M.
(-e./
np(0-P)
M- 100Xo.z 2o.01
NJooxo.1X02
P2< 4
tu 2-Atehe
tale
m- 80 -2.93
4
80-9.32
W
= 70. 63
71-100X0.7
= P(22 -l-69)
(?2 -0.92)
0.81
= P(2 -0.1)
P(2< O. 22)
D.527
(Y) P 0.70
Nj00x 0.90o.3
= P(22 0.22)
) 1 -.ET1
0 129
(v) = 0.48
7- J00X 0.61
P(2 2 )
|-r(2 20.64)
P( 22 ?|-)0 x0.45
Nlo0 xo-6sX0.3S
|- 0.39%2
b.103
(i) P= 0.63
-100x o. 63
Noxo.63 20.27
)-1(22|.·36)
| 0.95)S
,04 85
- P(?2 2-24)
- )-P(2can2u)
o.9 B75
o.o125
ot the
Aee thot the pokabi ity
he ml hypo fheas
reases
Cie. Pe tr eoh) dese de
We decheuse
igibi canty dhen
ole e u
to 0.6. So, TyPe I! eoh
we move
menKes