Python API reference
Distributions
The general univariate distribution interface: 38 families with density, quantile, seeded random generation, and fitting.
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.
Copulas
The seven bivariate copula families (copula_names()), constructed directly or fitted to paired data.
Multivariate distributions
The five multivariate distribution families (mvdist_names()): multivariate normal and Student-t, Dirichlet, multinomial, and bivariate empirical.
GEV convenience functions
Direct density, distribution, quantile, moments, and fitting functions for the Generalized Extreme Value distribution.
Observation data
Censored observation frames – historical and paleoflood intervals, perception thresholds, measurement uncertainty, and low outliers – plus the diagnostics computed off them.
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. |
Frequency analysis
The main flood-frequency analysis entry points.
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. |
Uncertainty and diagnostics
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.
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).
Interpolation and regression
Histogram binning, one- and two-dimensional interpolation with optional axis transforms, and ordinary least squares regression.
Sampling utilities
Quasi-random Sobol sequences, deterministic stratification of an interval, and joint exceedance probabilities under a dependency structure.
Links and trends
The Numerics link-function layer (identity, log, logit, and friends) and the trend models used by nonstationary distributions and models.
| Link |
A link function spec, mirroring the seven Numerics link functions and the five |
| link_function |
Construct a :class:Link. See :class:Link for the arguments. |
| link |
Evaluate a link function: real-space to link-space. |
| link_inverse |
Evaluate the inverse of a link function: link-space back to real-space. |
| link_derivative |
Evaluate a link function’s derivative with respect to x. |
| link_names |
List the twelve link types :func:link_function accepts. |
| trend_predict |
Evaluate a trend model. |
| trend_parameters |
The trend’s own model-parameter values, by name. |
| trend_names |
List the eleven trend types :func:corehydropy.models.trend accepts. |
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).
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.
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.
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. |