FitDist

Fit distributions using sim-tools and compare samples to real data.

Usage

Source

FitDist(
    data,
    metric_name,
)

Attributes

data: pd.Series

Time data to fit distribution to.

metric_name: str

Name of metric, used for plot titles.

mean: float

Mean of data.

stdev: float

Standard deviation of data.

min: float

Minimum value of data.

max: float

Maximum value of data.

mode: float
Mode of data. If there are several modes, it chooses the middle one.

Methods

Name Description
__init__() Create instance of FitDist.
fit() Create a sim-tools distribution instance.
fit_and_compare() Fit distributions and compare.

__init__()

Create instance of FitDist.

Usage

Source

__init__(data, metric_name)
Parameters
data: pd.Series

Time data to fit distribution to.

metric_name: str
Name of metric, used for plot titles.

fit()

Create a sim-tools distribution instance.

Usage

Source

fit(dist, seed)
Parameters
dist: str

Lower case name of distribution object in sim-tools to create.

seed: int
Random seed.

fit_and_compare()

Fit distributions and compare.

Usage

Source

fit_and_compare(dists=DISTRIBUTIONS, xmax=200, seed=42, n_plots=None)
Parameters
dists: str | list = DISTRIBUTIONS

Distribution name/s.

xmax: int = 200

Max for x axis in plot to help view easier with long tails.

seed: int = 42

Random seed.

n_plots: int = None
Number of plots to show (e.g., if 3, will show plots for top 3 distributions). If none specified, will show all.
Returns
figs: list of matplotlib.figure.Figure

Figures generated for the top n_plots distributions (histogram and Q-Q plot pairs).

ks_table: pd.DataFrame
Table of KS statistics and percentile/max comparisons, sorted by best fit first.