Skip to content

Commit 8f01137

Browse files
committed
Update proportion-plot.rst
- Dataset generation was breaking due to misnamed variable; fixed. - Originally did not ask user to import dabest; fixed.
1 parent 3a771df commit 8f01137

1 file changed

Lines changed: 28 additions & 14 deletions

File tree

docs/source/proportion-plot.rst

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,40 +9,54 @@ As of v2023.02.14, DABEST can be used to produce Cohen's *h* and the correspondi
99
where the values are limited to 0 (failure) and 1 (success). This means that the code is not suitable for
1010
analyzing proportion data that contains non-numeric values, such as strings like 'yes' and 'no'.
1111

12-
Create dataset for demo
13-
-----------------------
12+
Load libraries
13+
--------------
1414

1515
.. code-block:: python3
1616
:linenos:
1717
1818
1919
import numpy as np
2020
import pandas as pd
21+
import dabest
22+
23+
print("We're using DABEST v{}".format(dabest.__version__))
24+
25+
26+
.. parsed-literal::
27+
28+
We're using DABEST v2023.02.14
29+
30+
Create dataset for demo
31+
-----------------------
32+
33+
.. code-block:: python3
34+
:linenos:
2135
2236
np.random.seed(9999) # Fix the seed so the results are replicable.
2337
Ns = 40 # The number of samples taken from each population
2438
2539
# Create samples
2640
n = 1
27-
c1 = np.random.binomial(n, 0.2, size=N)
28-
c2 = np.random.binomial(n, 0.2, size=N)
29-
c3 = np.random.binomial(n, 0.8, size=N)
41+
c1 = np.random.binomial(n, 0.2, size=Ns)
42+
c2 = np.random.binomial(n, 0.2, size=Ns)
43+
c3 = np.random.binomial(n, 0.8, size=Ns)
3044
31-
t1 = np.random.binomial(n, 0.5, size=N)
32-
t2 = np.random.binomial(n, 0.2, size=N)
33-
t3 = np.random.binomial(n, 0.3, size=N)
34-
t4 = np.random.binomial(n, 0.4, size=N)
35-
t5 = np.random.binomial(n, 0.5, size=N)
36-
t6 = np.random.binomial(n, 0.6, size=N)
45+
t1 = np.random.binomial(n, 0.5, size=Ns)
46+
t2 = np.random.binomial(n, 0.2, size=Ns)
47+
t3 = np.random.binomial(n, 0.3, size=Ns)
48+
t4 = np.random.binomial(n, 0.4, size=Ns)
49+
t5 = np.random.binomial(n, 0.5, size=Ns)
50+
t6 = np.random.binomial(n, 0.6, size=Ns)
3751
3852
3953
# Add a `gender` column for coloring the data.
40-
females = np.repeat('Female', N / 2).tolist()
41-
males = np.repeat('Male', N / 2).tolist()
54+
females = np.repeat('Female', Ns / 2).tolist()
55+
males = np.repeat('Male', Ns / 2).tolist()
4256
gender = females + males
4357
4458
# Add an `id` column for paired data plotting.
45-
id_col = pd.Series(range(1, N + 1))
59+
id_col = pd.Series(range(1, Ns + 1))
4660
4761
# Combine samples and gender into a DataFrame.
4862
df = pd.DataFrame({'Control 1': c1, 'Test 1': t1,

0 commit comments

Comments
 (0)