From 64247ef1088db55b4cae914c6502d3f307cd7c31 Mon Sep 17 00:00:00 2001 From: Michael Dyer Date: Wed, 19 Jun 2024 23:35:50 +0200 Subject: [PATCH 1/3] Update x-axis of Geometric distribution --- charts/geometric.svg | 463 +++++++++++++++++---------------- src/distributions/geometric.py | 8 +- 2 files changed, 237 insertions(+), 234 deletions(-) diff --git a/charts/geometric.svg b/charts/geometric.svg index d0ae692..d26db99 100644 --- a/charts/geometric.svg +++ b/charts/geometric.svg @@ -6,7 +6,7 @@ - 2024-05-03T20:23:41.328657 + 2024-06-19T23:34:20.018189 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(#p3a74dad68a)" style="fill: #1f77b4"/> +" clip-path="url(#p3a74dad68a)" style="fill: #1f77b4"/> +" clip-path="url(#p3a74dad68a)" style="fill: #1f77b4"/> +" clip-path="url(#p3a74dad68a)" style="fill: #1f77b4"/> +" clip-path="url(#p3a74dad68a)" style="fill: #1f77b4"/> +" clip-path="url(#p3a74dad68a)" style="fill: #1f77b4"/> +" clip-path="url(#p3a74dad68a)" style="fill: #1f77b4"/> +" clip-path="url(#p3a74dad68a)" style="fill: #1f77b4"/> +" clip-path="url(#p3a74dad68a)" style="fill: #1f77b4"/> +" clip-path="url(#p3a74dad68a)" style="fill: #1f77b4"/> +" clip-path="url(#p3a74dad68a)" style="fill: #ff7f0e"/> +" clip-path="url(#p3a74dad68a)" style="fill: #ff7f0e"/> +" clip-path="url(#p3a74dad68a)" style="fill: #ff7f0e"/> +" clip-path="url(#p3a74dad68a)" style="fill: #ff7f0e"/> +" clip-path="url(#p3a74dad68a)" style="fill: #ff7f0e"/> +" clip-path="url(#p3a74dad68a)" style="fill: #ff7f0e"/> +" clip-path="url(#p3a74dad68a)" style="fill: #ff7f0e"/> +" clip-path="url(#p3a74dad68a)" style="fill: #ff7f0e"/> +" clip-path="url(#p3a74dad68a)" style="fill: #ff7f0e"/> +" clip-path="url(#p3a74dad68a)" style="fill: #ff7f0e"/> +" clip-path="url(#p3a74dad68a)" style="fill: #2ca02c"/> +" clip-path="url(#p3a74dad68a)" style="fill: #2ca02c"/> +" clip-path="url(#p3a74dad68a)" style="fill: #2ca02c"/> +" clip-path="url(#p3a74dad68a)" style="fill: #2ca02c"/> +" clip-path="url(#p3a74dad68a)" style="fill: #2ca02c"/> +" clip-path="url(#p3a74dad68a)" style="fill: #2ca02c"/> +" clip-path="url(#p3a74dad68a)" style="fill: #2ca02c"/> +" clip-path="url(#p3a74dad68a)" style="fill: #2ca02c"/> +" clip-path="url(#p3a74dad68a)" style="fill: #2ca02c"/> +" clip-path="url(#p3a74dad68a)" style="fill: #2ca02c"/> +" clip-path="url(#p3a74dad68a)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/> - - + - + + + + + + + + + + + + + + + + + + + + - - + + + - + - + - + - + - - + + + - + - + - + - + - - + + + - + - + - + - + - - + + + - + - + - + - + - - + + + - + - + - + - + - - + + + - + - + - + - + - - + + + - + - + - + - + - - + + + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1098,16 +1099,16 @@ z +" clip-path="url(#p3a74dad68a)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/> - - + @@ -1132,11 +1133,11 @@ z +" clip-path="url(#p3a74dad68a)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/> - + @@ -1152,11 +1153,11 @@ L 414.72 275.904 +" clip-path="url(#p3a74dad68a)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/> - + @@ -1172,11 +1173,11 @@ L 414.72 244.224 +" clip-path="url(#p3a74dad68a)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/> - + @@ -1192,11 +1193,11 @@ L 414.72 212.544 +" clip-path="url(#p3a74dad68a)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/> - + @@ -1212,11 +1213,11 @@ L 414.72 180.864 +" clip-path="url(#p3a74dad68a)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/> - + @@ -1232,11 +1233,11 @@ L 414.72 149.184 +" clip-path="url(#p3a74dad68a)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/> - + @@ -1252,11 +1253,11 @@ L 414.72 117.504 +" clip-path="url(#p3a74dad68a)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/> - + @@ -1272,11 +1273,11 @@ L 414.72 85.824 +" clip-path="url(#p3a74dad68a)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/> - + @@ -1564,7 +1565,7 @@ z - + diff --git a/src/distributions/geometric.py b/src/distributions/geometric.py index 57fed29..635c3ae 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 until first success') ax.set_ylabel('Probability') ax.set_xticks(outcomes) # set the ticks to be the outcome values From eac24dccf494909c2f4a696047a53396da95f54f Mon Sep 17 00:00:00 2001 From: Michael Dyer Date: Thu, 20 Jun 2024 16:54:38 +0200 Subject: [PATCH 2/3] Change "until" to "before" --- src/distributions/geometric.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/distributions/geometric.py b/src/distributions/geometric.py index 635c3ae..9dc7f5d 100644 --- a/src/distributions/geometric.py +++ b/src/distributions/geometric.py @@ -21,7 +21,7 @@ def save_to(directory: str, extension: str): # Adding title and labels ax.set_title('Geometric distribution') - ax.set_xlabel('Number of failures 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 From 6ff1cc8371bf2bdcafedda38450b69a418d4173c Mon Sep 17 00:00:00 2001 From: Michael Dyer Date: Thu, 20 Jun 2024 17:01:10 +0200 Subject: [PATCH 3/3] Update plot --- charts/geometric.svg | 225 ++++++++++++++++++++++--------------------- 1 file changed, 113 insertions(+), 112 deletions(-) diff --git a/charts/geometric.svg b/charts/geometric.svg index d26db99..c9a94ba 100644 --- a/charts/geometric.svg +++ b/charts/geometric.svg @@ -6,7 +6,7 @@ - 2024-06-19T23:34:20.018189 + 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(#p3a74dad68a)" 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"/> - - + @@ -328,11 +328,11 @@ z +" clip-path="url(#pba068d7941)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/> - + @@ -362,11 +362,11 @@ z +" clip-path="url(#pba068d7941)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/> - + @@ -406,11 +406,11 @@ z +" clip-path="url(#pba068d7941)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/> - + @@ -458,11 +458,11 @@ z +" clip-path="url(#pba068d7941)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/> - + @@ -497,11 +497,11 @@ z +" clip-path="url(#pba068d7941)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/> - + @@ -542,11 +542,11 @@ z +" clip-path="url(#pba068d7941)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/> - + @@ -592,11 +592,11 @@ z +" clip-path="url(#pba068d7941)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/> - + @@ -622,11 +622,11 @@ z +" clip-path="url(#pba068d7941)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/> - + @@ -681,11 +681,11 @@ z +" clip-path="url(#pba068d7941)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/> - + @@ -728,8 +728,8 @@ z - - + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + @@ -1099,16 +1081,16 @@ z +" clip-path="url(#pba068d7941)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/> - - + @@ -1133,11 +1115,11 @@ z +" clip-path="url(#pba068d7941)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/> - + @@ -1153,11 +1135,11 @@ L 414.72 275.904 +" clip-path="url(#pba068d7941)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/> - + @@ -1173,11 +1155,11 @@ L 414.72 244.224 +" clip-path="url(#pba068d7941)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/> - + @@ -1193,11 +1175,11 @@ L 414.72 212.544 +" clip-path="url(#pba068d7941)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/> - + @@ -1213,11 +1195,11 @@ L 414.72 180.864 +" clip-path="url(#pba068d7941)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/> - + @@ -1233,11 +1215,11 @@ L 414.72 149.184 +" clip-path="url(#pba068d7941)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/> - + @@ -1253,11 +1235,11 @@ L 414.72 117.504 +" clip-path="url(#pba068d7941)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/> - + @@ -1273,11 +1255,11 @@ L 414.72 85.824 +" clip-path="url(#pba068d7941)" style="fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square"/> - + @@ -1420,6 +1402,25 @@ Q 2381 3103 1925 3103 Q 1469 3103 1208 2742 Q 947 2381 947 1747 z +" transform="scale(0.015625)"/> + @@ -1565,7 +1566,7 @@ z - +