You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/examples/gallery/global_settings.md
+3-4Lines changed: 3 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ Some of the PreliZ default values are regulated by `preliz.rcParams`, a class si
19
19
20
20
## Preliz Configuration File
21
21
22
-
The `rcParams` class is generated and populated at import time. Preliz checks several locations for a file named `prelizrc` and, if found, prefers those settings over the library ones.
22
+
The `rcParams` class is generated and populated at import time. PreliZ checks several locations for a file named `prelizrc` and, if found, prefers those settings over the library ones.
23
23
24
24
The locations checked are the following:
25
25
@@ -32,9 +32,8 @@ The locations checked are the following:
32
32
The file is a simple text file with a structure similar to the following:
33
33
34
34
```text
35
-
36
-
stats.ci_kind : hdi
37
-
stats.ci_prob : 0.95
35
+
stats.ci_kind : eti
36
+
stats.ci_prob : 0.89
38
37
```
39
38
40
39
All available keys are listed below. The `prelizrc` file can have any subset of the keys, it isn't necessary to include them all. For those keys without a user defined default, the library one is used.
Copy file name to clipboardExpand all lines: docs/examples/gallery/working_with_distributions.md
+49-11Lines changed: 49 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,6 @@ kernelspec:
11
11
# Working with Distributions
12
12
13
13
```{jupyter-execute}
14
-
15
14
import preliz as pz
16
15
```
17
16
@@ -41,22 +40,21 @@ When we define the parameters of a distribution we will get more interesting pro
41
40
42
41
## Properties of Distributions
43
42
44
-
Once we have set the parameters of a distribution we can obtain a few of its properties. The summary method, returns the mean, median, standard deviation and lower and upper values for the highest density interval.
43
+
Once we have set the parameters of a distribution we can obtain a few of its properties. The summary method, returns the mean, median, standard deviation and lower and upper values for the equal-tailed interval (ETI).
45
44
46
45
```{jupyter-execute}
47
46
48
47
dist = pz.Beta(2, 5)
49
48
dist.summary()
50
49
```
51
-
52
-
The highest density interval is the shorter interval with a given mass. Following ArviZ, the default mass for these intervals is 0.94. For `az.summary()` and other functions in PreliZ, you can change it with the argument `mass`.
50
+
The ETI is the interval that contains a given mass of the distribution, with equal mass in both tails.cFollowing ArviZ, the default mass for these intervals is 0.89. For `pz.summary()` and other functions in PreliZ, you can change it with the argument `mass`.
53
51
54
52
```{jupyter-execute}
55
53
56
54
dist.summary(mass=0.7)
57
55
```
58
56
59
-
Additionally, out-of-the-box, we can compute the equal-tailed interval. This interval will define two tails with an equal mass of `(1-mass)/2`.
57
+
Additionally, out-of-the-box, we can compute the highest density interval (HDI), which is the shortest interval containing a given mass of the distribution.
60
58
61
59
```{jupyter-execute}
62
60
@@ -121,8 +119,13 @@ Many distributions in PreliZ can be defined using different sets of parameters.
121
119
```{jupyter-execute}
122
120
123
121
dist = pz.Gamma(mu=2, sigma=1)
124
-
dist.plot_pdf()
125
-
pz.Gamma(dist.alpha, dist.beta).plot_pdf(); # same distribution different parametrization.
122
+
dist.summary()
123
+
```
124
+
125
+
Now we can create the same distribution using the `alpha` and `beta` parameters.
126
+
127
+
```{jupyter-execute}
128
+
pz.Gamma(dist.alpha, dist.beta).summary()
126
129
```
127
130
128
131
## Visualizing distributions
@@ -163,14 +166,21 @@ pz.Gamma(2, 0.5).plot_cdf()
163
166
pz.Gamma(2, 1).plot_cdf()
164
167
```
165
168
166
-
and the inverse of the cdf.
169
+
Other functions that can be plotted are the inverse of the CDF, `plot_ppf` (also known as percent point function), survival function (`plot_sf`), and the inverse survival function (`plot_isf`).
170
+
171
+
Alternatively, we can use the top-level `pz.plot()` function to plot any of these functions.
167
172
168
173
```{jupyter-execute}
174
+
pz.plot(pz.Gamma(2, 0.5));
175
+
```
169
176
170
-
pz.Gamma(2, 0.5).plot_ppf()
171
-
pz.Gamma(2, 1).plot_ppf()
177
+
The default is to plot the PDF. But we can plot any other function as well. For instance, for the survival function:
178
+
179
+
```{jupyter-execute}
180
+
pz.plot(pz.Gamma(2, 0.5), kind="sf");
172
181
```
173
182
183
+
174
184
If we are not very familiar with a distribution, we may want to explore how the parameters affects the “shape” of the distribution. This could be easier to do interactively.
175
185
176
186
```{jupyter-execute}
@@ -237,9 +247,37 @@ PreliZ supports exporting distributions. Currently, only PyMC and Bambi are supp
237
247
```{jupyter-execute}
238
248
239
249
pz.Normal(0, 1).to_pymc()
250
+
```
251
+
252
+
```{jupyter-execute}
253
+
240
254
pz.Normal(0, 1).to_bambi()
241
255
```
242
256
243
257
For these methods to work you need to have installed PyMC and/or Bambi.
244
258
245
-
In other notebooks we will discuss methods more directly focus on prior elicitation, and also other ways to interact with PPLs.
259
+
260
+
We can also go into the opposite direction and create PreliZ distributions from PyMC distributions.
0 commit comments