diff --git a/charts/geometric.svg b/charts/geometric.svg index d0ae692..c9a94ba 100644 --- a/charts/geometric.svg +++ b/charts/geometric.svg @@ -6,7 +6,7 @@ - 2024-05-03T20:23:41.328657 + 2024-06-20T17:01:06.224764 image/svg+xml @@ -43,7 +43,7 @@ L 65.04 307.584 L 65.04 244.224 L 57.6 244.224 z -" clip-path="url(#p53dfc6246f)" style="fill: #1f77b4"/> +" clip-path="url(#pba068d7941)" style="fill: #1f77b4"/> +" clip-path="url(#pba068d7941)" style="fill: #1f77b4"/> +" clip-path="url(#pba068d7941)" style="fill: #1f77b4"/> +" clip-path="url(#pba068d7941)" style="fill: #1f77b4"/> +" clip-path="url(#pba068d7941)" style="fill: #1f77b4"/> +" clip-path="url(#pba068d7941)" style="fill: #1f77b4"/> +" clip-path="url(#pba068d7941)" style="fill: #1f77b4"/> +" clip-path="url(#pba068d7941)" style="fill: #1f77b4"/> +" clip-path="url(#pba068d7941)" style="fill: #1f77b4"/> +" clip-path="url(#pba068d7941)" style="fill: #1f77b4"/> +" clip-path="url(#pba068d7941)" style="fill: #ff7f0e"/> +" clip-path="url(#pba068d7941)" style="fill: #ff7f0e"/> +" clip-path="url(#pba068d7941)" style="fill: #ff7f0e"/> +" clip-path="url(#pba068d7941)" style="fill: #ff7f0e"/> +" clip-path="url(#pba068d7941)" style="fill: #ff7f0e"/> +" clip-path="url(#pba068d7941)" style="fill: #ff7f0e"/> +" clip-path="url(#pba068d7941)" style="fill: #ff7f0e"/> +" clip-path="url(#pba068d7941)" style="fill: #ff7f0e"/> +" clip-path="url(#pba068d7941)" style="fill: #ff7f0e"/> +" clip-path="url(#pba068d7941)" style="fill: #ff7f0e"/> +" clip-path="url(#pba068d7941)" style="fill: #2ca02c"/> +" clip-path="url(#pba068d7941)" style="fill: #2ca02c"/> +" clip-path="url(#pba068d7941)" style="fill: #2ca02c"/> +" clip-path="url(#pba068d7941)" style="fill: #2ca02c"/> +" clip-path="url(#pba068d7941)" style="fill: #2ca02c"/> +" clip-path="url(#pba068d7941)" style="fill: #2ca02c"/> +" clip-path="url(#pba068d7941)" style="fill: #2ca02c"/> +" clip-path="url(#pba068d7941)" style="fill: #2ca02c"/> +" clip-path="url(#pba068d7941)" style="fill: #2ca02c"/> +" clip-path="url(#pba068d7941)" style="fill: #2ca02c"/> +" clip-path="url(#pba068d7941)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/> - - + - + + + + + + + + + + + + + + + + + + + + - - + + + - + - + - + - + - - + + + - + - + - + - + - - + + + - + - + - + - + - - + + + - + - + - + - + - - + + + - + - + - + - + - - + + + - + - + - + - + - - + + + - + - + - + - + - - + + + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - + + - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1098,16 +1081,16 @@ z +" clip-path="url(#pba068d7941)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/> - - + @@ -1132,11 +1115,11 @@ z +" clip-path="url(#pba068d7941)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/> - + @@ -1152,11 +1135,11 @@ L 414.72 275.904 +" clip-path="url(#pba068d7941)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/> - + @@ -1172,11 +1155,11 @@ L 414.72 244.224 +" clip-path="url(#pba068d7941)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/> - + @@ -1192,11 +1175,11 @@ L 414.72 212.544 +" clip-path="url(#pba068d7941)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/> - + @@ -1212,11 +1195,11 @@ L 414.72 180.864 +" clip-path="url(#pba068d7941)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/> - + @@ -1232,11 +1215,11 @@ L 414.72 149.184 +" clip-path="url(#pba068d7941)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/> - + @@ -1252,11 +1235,11 @@ L 414.72 117.504 +" clip-path="url(#pba068d7941)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/> - + @@ -1272,11 +1255,11 @@ L 414.72 85.824 +" clip-path="url(#pba068d7941)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/> - + @@ -1419,6 +1402,25 @@ Q 2381 3103 1925 3103 Q 1469 3103 1208 2742 Q 947 2381 947 1747 z +" transform="scale(0.015625)"/> + @@ -1564,7 +1566,7 @@ z - + diff --git a/src/distributions/geometric.py b/src/distributions/geometric.py index 57fed29..9dc7f5d 100644 --- a/src/distributions/geometric.py +++ b/src/distributions/geometric.py @@ -7,7 +7,7 @@ def save_to(directory: str, extension: str): # Possible values of p for the distribution p_values = [0.2, 0.5, 0.8] # Possible outcomes for a Geometric distributed variable - outcomes = np.arange(1, 11) + outcomes = np.arange(0, 10) # Creating the figure and the axis fig, ax = plt.subplots() @@ -15,11 +15,13 @@ def save_to(directory: str, extension: str): # Plotting the PMF for each value of p for i, p in enumerate(p_values): - ax.bar(outcomes + i * width - width, geom.pmf(outcomes, p), width=width, label=f'p = {p}') + # Specify loc=-1 correct for the difference in the definition of the geometric distribution in scipy + # and the definition in the rand crate + ax.bar(outcomes + i * width - width, geom.pmf(outcomes, p, loc=-1), width=width, label=f'p = {p}') # Adding title and labels ax.set_title('Geometric distribution') - ax.set_xlabel('Number of trials until first success') + ax.set_xlabel('Number of failures before first success') ax.set_ylabel('Probability') ax.set_xticks(outcomes) # set the ticks to be the outcome values