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.

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,
    n_bins=200,
    time_unit="minutes"
)
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.

n_bins: int = 200

Number of histogram bins.

time_unit: str = "minutes"
Display unit for plot labels. This does not convert data values.
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.