@@ -154,14 +154,17 @@ The PMF shows two bars: P(X=0) = 0.7 for a negative test and P(X=1) = 0.3 for a
154154:tags: [remove-input, remove-output]
155155
156156# Plotting the CDF
157+ k_values_viz = [0, 1]
157158cdf_values_viz = bernoulli_viz.cdf(k_values_viz)
158159
159160plt.figure(figsize=(8, 4))
160- plt.step(k_values_viz, cdf_values_viz, where='post', color='darkgreen', linewidth=2)
161+ # Add points to show the full step function including the start at 0
162+ plt.step([-0.5] + k_values_viz, [0] + list(cdf_values_viz), where='post', color='darkgreen', linewidth=2)
161163plt.title(f"Bernoulli CDF (p={p_viz})")
162164plt.xlabel("Outcome")
163165plt.ylabel("Cumulative Probability P(X <= k)")
164166plt.ylim(0, 1.1)
167+ plt.xlim(-0.5, 1.5)
165168plt.xticks([0, 1])
166169plt.grid(True, which='both', linestyle='--', linewidth=0.5, alpha=0.6)
167170plt.savefig('ch07_bernoulli_cdf_generic.svg', format='svg', bbox_inches='tight')
@@ -256,11 +259,13 @@ The PMF shows the probability of each outcome. With p = 0.1, "Negative" has prob
256259cdf_values = bernoulli_rv.cdf(k_values)
257260
258261plt.figure(figsize=(8, 4))
259- plt.step(k_values, cdf_values, where='post', color='darkgreen', linewidth=2)
262+ # Add points to show the full step function including the start at 0
263+ plt.step([-0.5] + k_values, [0] + list(cdf_values), where='post', color='darkgreen', linewidth=2)
260264plt.title(f"Bernoulli CDF (p={p_positive})")
261265plt.xlabel("Outcome")
262266plt.ylabel("Cumulative Probability P(X <= k)")
263267plt.ylim(0, 1.1)
268+ plt.xlim(-0.5, 1.5)
264269plt.xticks([0, 1])
265270plt.grid(True, which='both', linestyle='--', linewidth=0.5, alpha=0.6)
266271plt.savefig('ch07_bernoulli_cdf.svg', format='svg', bbox_inches='tight')
0 commit comments