Python API reference

Distributions

The general univariate distribution interface: 38 families with density, quantile, seeded random generation, and fitting.

Distribution A univariate distribution from the ported Numerics library.
distribution_names List the supported distribution families.

Composite distributions

Five distributions built from other distributions rather than a flat parameter vector – truncation, mixtures, competing risks, empirical, and kernel density. Each returns a Distribution accepted by every method on that class.

dist_truncated Truncate a distribution.
dist_mixture Mixture distribution.
dist_competing_risks Competing-risks distribution.
dist_empirical Empirical distribution.
dist_kde Kernel density distribution.

Copulas

The seven bivariate copula families (copula_names()), constructed directly or fitted to paired data.

Copula A bivariate copula.
copula_fit Fit a bivariate copula to data.
copula_names List the supported copula families.

Multivariate distributions

The five multivariate distribution families (mvdist_names()): multivariate normal and Student-t, Dirichlet, multinomial, and bivariate empirical.

MultivariateDistribution A multivariate distribution from the ported Numerics library.
mvdist_normal Construct a multivariate normal distribution.
mvdist_student_t Construct a multivariate Student-t distribution.
mvdist_dirichlet Construct a Dirichlet distribution.
mvdist_multinomial Construct a multinomial distribution.
mvdist_bivariate_empirical Construct a bivariate empirical distribution.
mvdist_names List the supported multivariate distribution families.

GEV convenience functions

Direct density, distribution, quantile, moments, and fitting functions for the Generalized Extreme Value distribution.

GeneralizedExtremeValue
dgev GEV probability density at x.
pgev GEV cumulative distribution at q.
qgev GEV quantile (inverse CDF) at probability p.
gev_moments GEV distribution moments and support.
gev_fit Fit a GEV distribution to sample x.

Observation data

Censored observation frames – historical and paleoflood intervals, perception thresholds, measurement uncertainty, and low outliers – plus the diagnostics computed off them.

AnalysisData Censored observation data for an analysis.
analysis_data Construct an :class:AnalysisData frame.
analysis_data_summary Run the plotting-position and threshold cascade over an observation frame.
analysis_data_hypothesis_test A hypothesis test on an observation record.
analysis_data_statistics Summary statistics for an observation record.
threshold_diagnostics Threshold selection diagnostics for peaks-over-threshold analysis.

Models

The nine RMC.BestFit model families as plain specs, with nonstationary trends and per-parameter bounds and priors. Pass one to any analysis in place of a data sequence.

Model A model spec: the family, its data, and any trends, constraints, or fixed values.
model_univariate A single distribution fit to a record.
model_mixture A weighted mixture of two or three component distributions.
model_competing_risks The maximum of several independent flood-generating processes.
model_point_process A point process over exceedances of a threshold.
model_bulletin17c The Bulletin 17C log-Pearson Type III flood-frequency model.
model_ar An autoregressive AR(p) model.
model_ma A moving-average MA(q) model.
model_arima An ARIMA(p, d, q) model.
model_arimax An ARIMAX(p, d, q, b) model with covariates.
model_spatial_gev The Renard hierarchical spatial GEV model.
model_rating_curve A BaRatin stage-discharge rating curve.
model_bivariate Two fixed univariate marginals coupled by a bivariate copula.
Trend A nonstationary trend on one distribution parameter.
trend Construct a :class:Trend. See :class:Trend for the arguments.
ModelParameter Bounds, a fixed flag, a prior, or a starting value for one model parameter.
model_parameter Construct a :class:ModelParameter. See :class:ModelParameter for the arguments.
model_validate Check a model’s data and parameters and report anything that would stop it being fit.
model_simulate Draw a seeded random sample from a model at its current parameter values.
model_log_likelihood Evaluate a model’s log-likelihood, decomposed into its data and prior halves.
model_parameters The model’s current parameter vector, with names where the model exposes them.

Point-estimate fits

Maximum likelihood and maximum a posteriori point fits, with Hessian-based covariance and profile-likelihood confidence intervals.

Fit A fitted model: parameter estimates plus whichever estimator diagnostics the target
fit_mle Maximum likelihood fit.
fit_map Maximum a posteriori fit.

Bayesian and GMM fits

fit_bayesian Bayesian MCMC fit.
fit_gmm Generalized method of moments fit (Bulletin 17C).
fit_gmm_moments Fit your own moment conditions by the generalized method of moments.
fit_diagnostics Estimation diagnostics for a fit.
quantile_variance Delta-method variance of a fitted quantile.

Frequency analysis

The main flood-frequency analysis entry points.

univariate_analysis Bayesian univariate frequency analysis.
fit_distributions Fit and rank the 15 candidate distributions by maximum likelihood.
bulletin17c_analysis Bulletin 17C (log-Pearson Type III) flood-frequency analysis.
composite_analysis Composite frequency analysis over one child analysis per families entry.

Model-family analyses

mixture_analysis Bayesian mixture-model frequency analysis.
competing_risk_analysis Bayesian competing-risk frequency analysis.
point_process_analysis Bayesian point-process (peaks-over-threshold) frequency analysis.
spatial_gev_analysis Hierarchical spatial-GEV frequency analysis over gauged sites.
bivariate_analysis Bivariate (copula) joint-exceedance frequency analysis over two fixed marginals.
coincident_frequency_analysis Coincident-frequency analysis: a fitted bivariate copula + an M x N response surface.
rating_curve_analysis Stage-discharge rating-curve frequency analysis.

Time series

ar_analysis Bayesian autoregressive AR(p) time-series analysis.
ma_analysis Bayesian moving-average MA(q) time-series analysis.
arima_analysis Bayesian ARIMA(p,d,q) time-series analysis.
arimax_analysis Bayesian ARIMAX(p,d,q) time-series analysis with a deterministic trend.

MCMC

mcmc_sample Sample the posterior of a distribution’s parameters by MCMC.
mcmc_posterior Sample your own posterior by MCMC.

Uncertainty and diagnostics

bootstrap_analysis Parametric bootstrap confidence bands for a fitted distribution.
bootstrap_custom Bootstrap your own statistic.
estimation_diagnostics Bayesian estimation diagnostics (leverage / influence / prior influence).
prior_predictive_check Prior predictive check: sample from the model priors, simulate, summarize.
posterior_predictive_check Posterior predictive check: fit an MCMC, draw replicates, compute common p-values.

Statistics utilities

mgbt_test Multiple Grubbs-Beck low-outlier test.
box_cox_lambda Fit the Box-Cox transformation exponent by maximum likelihood.
box_cox Box-Cox power transformation of x with exponent lambda_.
box_cox_inverse Inverse Box-Cox transformation of x with exponent lambda_.
yeo_johnson_lambda Fit the Yeo-Johnson transformation exponent by maximum likelihood.
yeo_johnson Yeo-Johnson power transformation of x with exponent lambda_.
yeo_johnson_inverse Inverse Yeo-Johnson transformation of x with exponent lambda_.
plotting_positions Empirical plotting positions for a sample of size n.
latin_hypercube Latin hypercube sample of uniform [0, 1] probabilities.

Correlation and goodness of fit

Correlation coefficients and the GoodnessOfFit metrics (continuous and binary classification), plus the information criteria and model-weight functions used to rank candidate fits.

correlation Correlation between two samples, or a correlation matrix.
goodness_of_fit Goodness-of-fit metrics for a modeled series.
classification_metrics Classification metrics for two binary label vectors.
gof_test Goodness-of-fit test statistic for a fitted distribution.
gof_rmse Root mean squared error of a fitted distribution.
aic Akaike Information Criterion.
aicc Small-sample-corrected Akaike Information Criterion.
bic Bayesian Information Criterion.
aic_weights Model weights from a vector of AIC values.
rmse_weights Model weights from a vector of RMSE values.

Statistics

Sample moments, L-moments, ranks and percentiles, running (online) statistics and covariance, autocorrelation and cross-correlation, and the discrete Fourier transform.

summary_statistics Summary statistics for a sample.
product_moments Product moments of a sample.
l_moments L-moments of a sample.
ranks Ranks of a sample.
percentile Percentiles of a sample.
RunningStatistics Streaming summary statistics accumulator.
running_statistics Streaming summary statistics.
RunningCovariance Streaming covariance and correlation matrix accumulator.
running_covariance Streaming covariance and correlation matrix.
autocorrelation Autocorrelation, autocovariance, or partial autocorrelation function.
cross_correlation Cross-correlation of two series.
dft Discrete Fourier transform.
dft_real Discrete Fourier transform of real-valued data.

Hypothesis tests

The twelve ported Numerics one- and two-sample parametric and nonparametric hypothesis tests (t-tests, the F-test and its two-model form, Jarque-Bera, Wald-Wolfowitz, Ljung-Box, Mann-Whitney, Mann-Kendall, the linear trend test).

hypothesis_test Hypothesis tests.

Interpolation and regression

Histogram binning, one- and two-dimensional interpolation with optional axis transforms, and ordinary least squares regression.

histogram Bin a sample into a histogram.
interpolate Interpolate a paired series.
interpolate_2d Interpolate a 2D grid (bilinear interpolation).
LinearRegressionResult Fitted ordinary least squares model, mirroring the C# LinearRegression class.
linear_regression Ordinary least squares by singular value decomposition.

Sampling utilities

Quasi-random Sobol sequences, deterministic stratification of an interval, and joint exceedance probabilities under a dependency structure.

sobol_sequence Sobol quasi-random low-discrepancy sequence.
stratify Stratify an axis into equal-width bins.
joint_probability Joint probability of multiple events.

Optimizers and network routing

The fourteen ported Numerics optimizers (differential evolution, particle swarm, shuffled complex evolution, simulated annealing, multi-start, MLSL, BFGS, Powell, ADAM, gradient descent, Nelder-Mead, Brent, golden section, augmented Lagrange) over a user-written Python objective, and the Dijkstra shortest-path solver from the same upstream Optimization namespace.

OptimResult The result of :func:optim_minimize/:func:optim_maximize.
Constraint One constraint for the augmented Lagrange optimizer.
optim_minimize Minimize a user-written objective.
optim_maximize Maximize a user-written objective. See :func:optim_minimize for the arguments.
shortest_path Solve the shortest paths through a network.

Root finding, integration and differentiation

The ported Numerics Brent root finder, adaptive Gauss-Kronrod integrator and NumericalDerivative routines over a user-written Python function.

root_find Find a root of a user-written function.
root_find_system Solve a system of nonlinear equations.
quadrature Integrate a user-written function over a finite interval.
quadrature_2d Integrate a user-written function of two variables over a rectangle.
quadrature_nd Integrate a user-written function over a multidimensional box.
QuadratureResult The value :func:quadrature returns: the integral, with the run’s report attached.
ode_solve Solve a user-written ordinary differential equation.
derivative Take the first derivative of a single-variable function by central difference.
gradient Take the gradient of a function of a parameter vector.
hessian Take the Hessian matrix of a function of a parameter vector.

Linear algebra and special functions

The ported Numerics QRDecomposition (Householder reflections) and GaussJordanElimination linear-algebra routines, the Debye and Evaluate special functions, and the two non-tabular IUnivariateFunction implementations (LinearFunction, PowerFunction).

qr_decomposition QR decomposition.
qr_solve Solve a linear system by QR decomposition.
gauss_jordan Gauss-Jordan elimination.
debye The Debye function.
polynomial_eval Evaluate a polynomial.
univariate_function Evaluate a univariate function.

Paired-data curves

The ported Paired Data subsystem (OrderedPairedData, UncertainOrderedPairedData) and its third IUnivariateFunction implementation, TabularFunction: interpolation and area under a curve, three simplification algorithms, sampling an uncertain curve at its mean or a quantile, and evaluating a tabular function built from that curve.

curve_interpolate Interpolate a paired x-y curve.
curve_area Area under a paired x-y curve.
curve_simplify Simplify a paired x-y curve.
uncertain_curve_sample Sample an uncertain paired curve.
tabular_function Evaluate a tabular function.

Machine learning

The ported Numerics.MachineLearning layer: three unsupervised methods (k-means, Gaussian mixture models, Jenks natural breaks) and five supervised ones (decision trees, random forests, k-nearest neighbors, Gaussian naive Bayes, and generalized linear models). Each trains and answers in one call; a seeded fit is reproducible and agrees bit for bit with the identical call in R.

ml_kmeans k-means clustering.
ml_gaussian_mixture Gaussian mixture model.
ml_jenks_breaks Jenks natural breaks classification.
ml_decision_tree Decision tree regression or classification.
ml_random_forest Random forest regression or classification.
ml_knn k-nearest-neighbors regression or classification.
ml_naive_bayes Gaussian naive Bayes classification.
ml_glm Generalized linear model.

Time-series container

The ported Numerics TimeSeries container. A TimeSeries carries dated observations on a stated interval; its methods smooth, fill, clip, re-interval, summarize, reduce to annual maxima or peaks over a threshold, decompose, and resample. Seeded resampling agrees bit for bit with the identical call in R.

TimeSeries A time series: an ordered collection of (date, value) ordinates on a time interval.
ts_interval_names The time intervals a :class:TimeSeries can carry, in the library’s own order.

The generator a callback is handed

Drawing from the core’s seeded random number generator inside a function you write, so the run stays reproducible and agrees with the identical run in R.

Rng The seeded random number generator a corehydro callback is handed.