Mixins
Mixins to support the plotting and slicing of the distribution parameters. They are only required for creating new distributions or for understanding the internals.
ContinuousPlotDistMixin
Bases: PlotDistMixin
Functionality for plot_pdf method of continuous distributions.
Source code in conjugate/plot.py
plot_pdf(ax=None, **kwargs)
Plot the pdf of distribution
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ax |
Optional[Axes]
|
matplotlib Axes, optional |
None
|
**kwargs |
Additonal kwargs to pass to matplotlib |
{}
|
Returns:
Type | Description |
---|---|
Axes
|
new or modified Axes |
Raises:
Type | Description |
---|---|
ValueError
|
If the max_value is not set. |
Source code in conjugate/plot.py
DirichletPlotDistMixin
Bases: ContinuousPlotDistMixin
Plot the pdf using samples from the dirichlet distribution.
Source code in conjugate/plot.py
plot_pdf(ax=None, samples=1000, random_state=None, **kwargs)
Plots the pdf by sampling from the distribution.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ax |
Optional[Axes]
|
matplotlib Axes, optional |
None
|
samples |
int
|
number of samples to take from the distribution |
1000
|
random_state |
random state to use for sampling |
None
|
|
**kwargs |
Additonal kwargs to pass to matplotlib |
{}
|
Returns:
Type | Description |
---|---|
Axes
|
new or modified Axes |
Source code in conjugate/plot.py
DiscretePlotMixin
Bases: PlotDistMixin
Adding the plot_pmf method to class.
Source code in conjugate/plot.py
plot_pmf(ax=None, mark='o-', **kwargs)
Plot the pmf of distribution
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ax |
Optional[Axes]
|
matplotlib Axes, optional |
None
|
mark |
str
|
matplotlib line style |
'o-'
|
**kwargs |
Additonal kwargs to pass to matplotlib |
{}
|
Returns:
Type | Description |
---|---|
Axes
|
new or modified Axes |
Raises:
Type | Description |
---|---|
ValueError
|
If the max_value is not set. |
Source code in conjugate/plot.py
PlotDistMixin
Base mixin in order to support plotting. Requires the dist attribute of the scipy distribution.
Source code in conjugate/plot.py
set_bounds(lower, upper)
resolve_label(label, yy)
https://stackoverflow.com/questions/73662931/matplotlib-plot-a-numpy-array-as-many-lines-with-a-single-label
Source code in conjugate/plot.py
SliceMixin
Mixin in order to slice the parameters