User Reference Guide

The following documents the high-level functions that a typical user will may want to use. Note there are many more lower-level functions that may be of interest to advanced users. See the function doc-strings within submodule files for documentation of such functions.

pyapprox.analysis Package

The pyapprox.analysis module implements a number of popular tools for model analysis.

Functions

generate_parameter_sweeps_and_plot_from_variable(...)

Plot parameter sweeps of a function.

gpc_sobol_sensitivities(pce, variable[, ...])

Compute variance based sensitivity metrics from a polynomial chaos expansion

sparse_grid_sobol_sensitivities(sparse_grid)

Compute sensitivity indices from a sparse grid by converting it to a polynomial chaos expansion

morris_sensitivities(fun, variable, ...[, ...])

Compute sensitivity indices by constructing an adaptive polynomial chaos expansion.

plot_main_effects(main_effects, ax[, ...])

Plot the main effects in a pie chart showing relative size.

plot_total_effects(total_effects, ax[, ...])

Plot the total effects in a bar chart showing relative size.

plot_interaction_values(interaction_values, ...)

Plot sobol indices in a pie chart showing relative size.

run_sensitivity_analysis(method, fun, ...)

Compute sensitivity indices for a model.

plot_sensitivity_indices(result[, axs, ...])

pyapprox.bayes Package

The pyapprox.bayes module implements a number of popular tools for Bayesian Inference.

Functions

laplace_posterior_approximation_for_linear_models(...)

Compute the mean and covariance of the Laplace posterior of a linear model with a Gaussian prior

Classes

GaussianNetwork(graph)

A Bayesian network of linear Gaussian models.

pyapprox.benchmarks Package

The pyapprox.benchmarks module implements numerous benchmarks from the modeling literature.

Functions

setup_ishigami_function(a, b)

Setup the Ishigami function benchmark

setup_sobol_g_function(nvars)

Setup the Sobol-G function benchmark

setup_oakley_function()

Setup the Oakely function benchmark

setup_genz_function(nvars, test_name[, ...])

Setup one of the six Genz integration benchmarks \(f_d(x):\mathbb{R}^D\to\mathbb{R}\), where \(x=[x_1,\ldots,x_D]^\top\).

setup_rosenbrock_function(nvars)

Setup the Rosenbrock function benchmark

setup_benchmark(name, **kwargs)

Setup a PyApprox benchmark.

setup_piston_benchmark()

Returns:

setup_wing_weight_benchmark()

Setup the wing weight model benchmark.

setup_polynomial_ensemble([nmodels])

Return an ensemble of 5 univariate models of the form

list_benchmarks()

List the names of all available benchmarks

setup_advection_diffusion_kle_inversion_benchmark([...])

A benchmark for testing maximum likelihood estimation and Bayesian inference algorithms that involves learning the uncertain parameters \(\rv\) from synthteically generated observational data using the model

setup_multi_index_advection_diffusion_benchmark([...])

This benchmark is used to test methods for forward propagation of uncertainty.

Classes

Benchmark

Contains functions and results needed to implement known benchmarks.

pyapprox.expdesign Package

The pyapprox.expdesign module implements a number of popular tools for designing experiments

Functions

sobol_sequence(nvars, nsamples[, ...])

Generate a multivariate Sobol sequence

halton_sequence(num_vars, nsamples[, ...])

Generate a multivariate Halton sequence

optimal_experimental_design(design_pts, fun, ...)

Compute optimal experimental designs for models of the form

get_bayesian_oed_optimizer(short_oed_type, ...)

Initialize a Bayesian OED optimizer.

Classes

AlphabetOptimalDesign(criteria, design_factors)

Construct optimal experimental designs using functions of the fisher information matrix

NonLinearAlphabetOptimalDesign(criteria, ...)

Construct minimax optimal experimental designs of non-linear models by sampling fisher information matrix at multiple uncertain parameter realizations.

BayesianBatchKLOED(ndesign_candidates, ...)

Compute open-loop OED my maximizing KL divergence between the prior and posterior.

BayesianBatchDeviationOED(...[, qoi_fun, ...])

Compute open-loop OED by minimizing the deviation on the push forward of the posterior through a QoI model.

BayesianSequentialOED(obs_process)

Compute sequential optimal experimental designs that collect data and use this to inform the choice of subsequent design locations.

BayesianSequentialKLOED(ndesign_candidates, ...)

Compute closed-loop OED my maximizing KL divergence between the prior and posterior.

BayesianSequentialDeviationOED(...[, ...])

Compute closed-loop OED by minimizing the deviation on the push forward of the posterior through a QoI model.

AbstractBayesianOED(ndesign_candidates, ...)

Base Bayesian OED class

pyapprox.interface Package

The pyapprox.interface module implements a number of tools for interfacing with numerical models

Functions

evaluate_1darray_function_on_2d_array(...[, ...])

Evaluate a function at a set of samples using a function that only takes one sample at a time

Classes

WorkTrackingModel(function[, base_model, ...])

Keep track of the wall time needed to evaluate a function.

TimerModel(function[, base_model])

Return the wall-time needed to evaluate a function at each sample as an additional quantity of interest.

ModelEnsemble(functions[, names])

Wrapper class to allow easy one-dimensional indexing of models in an ensemble.

PoolModel(function, max_eval_concurrency[, ...])

Evaluate a function at multiple samples in parallel using multiprocessing.Pool

AynchModel(shell_command[, ...])

Evaluate a model in parallel when model instances are invoked by a shell script.

FileIOModel(shell_command[, ...])

Evaluate a model by writing parameters to file, running a shell script and reading the results from the file created by the shell script.

DataFunctionModel(function[, data, ...])

Create a queriable function that stores samples and associated function values and returns stored values for samples in the database or otherwise evaluate the function.

MultiIndexModel(setup_model, config_values)

Define a multi-index model to be used for multi-index collocation

pyapprox.multifidelity Package

The pyapprox.multifidelity module implements numerous multi-fidelity algorithms for quantifying uncertainty and building surrgates from multiple models of varying cost and fidelity.

Functions

get_estimator(estimator_types, stat, costs)

Parameters:

plot_estimator_variance_reductions(...[, ...])

Plot the variance reduction (relative to single model MC) for a list of optimized estimtors.

plot_estimator_sample_allocation_comparison(...)

Plot the number of samples allocated to each model for a set of estimators

plot_correlation_matrix(corr_matrix[, ax, ...])

Plot a correlation matrix

plot_model_costs(costs[, model_names, ax])

estimate_model_ensemble_covariance(...)

Estimate the covariance of a model ensemble from a set of pilot samples

pyapprox.optimization Package

The pyapprox.optimization module implements a number of popular tools for risk-averse regression and design.

Functions

solve_FSD_constrained_least_squares_smooth(...)

Solve first order stochastic dominance (FSD) constrained least squares

solve_SSD_constrained_least_squares_smooth(...)

Solve second order stochastic dominance (SSD) constrained least squares

cvar_regression(basis_matrix, values, alpha)

Solve conditional value at risk (CVaR) regression problems.

solve_quantile_regression(tau, samples, ...)

Solve quantile regression problems.

solve_least_squares_regression(samples, ...)

Solve the safety margins least squares regression problem.

pyapprox.surrogates Package

The pyapprox.surrogates module implements numerous algorithms for constructing surrogates.

Functions

get_gauss_quadrature_rule_from_marginal(...)

Return the quadrature rule associated with the marginal.

tensor_product_barycentric_lagrange_interpolation(...)

Use tensor-product Barycentric Lagrange interpolation to approximate a function.

tensor_product_piecewise_polynomial_interpolation(...)

Use tensor-product piecewise polynomial basis to interpolate a function.

get_tensor_product_piecewise_polynomial_quadrature_rule(...)

Compute the nodes and weights needed to integrate a 2D function using piecewise linear interpolation

approximate(train_samples, train_vals, method)

Approximate a scalar or vector-valued function of one or more variables from a set of points provided by the user

adaptive_approximate(fun, variable, method)

Adaptive approximation of a scalar or vector-valued function of one or more variables.

Classes

PolynomialChaosExpansion()

A polynomial chaos expansion for independent random variables.

APC([compute_moment_matrix_function, ...])

A polynomial chaos expansion for dependent random variables.

AdaptiveInducedPCE(num_vars[, cond_tol, ...])

An adaptive PCE built using induced sampling and generalized sparse grid like refinement.

AdaptiveLejaPCE(num_vars, candidate_samples)

An adaptive PCE built using multivariate Leja sequences and generalized sparse grid like refinement.

CombinationSparseGrid(num_vars[, basis_type])

Adaptive sparse grid that uses the combination technique.

pyapprox.util Package

The pyapprox.util module implements numerous foundational utilities.

Functions

cartesian_product(input_sets[, elem_size])

Compute the cartesian product of an arbitray number of sets.

outer_product(input_sets[, axis])

Construct the outer product of an arbitary number of sets.

check_gradients(fun, jac, zz[, plot, disp, ...])

Compare a user specified jacobian with the jacobian computed with finite difference with multiple step sizes.

plot_2d_samples(samples[, ax])

Plot 2D samples

pyapprox.variables Package

The pyapprox.variables module provides tools for creating and transforming multivariate random variables.

Functions

print_statistics(samples[, values, ...])

Print statistics about a set of samples and associated values

combine_uncertain_and_bounded_design_variables(...)

Convert design variables to random variables defined over them optimization bounds.

Classes

IndependentMarginalsVariable(unique_variables)

Class representing independent random variables

GaussCopulaVariable(marginals, x_correlation)

Multivariate random variable with Gaussian correlation and arbitrary marginals

JointVariable()

Base class for multivariate variables.

AffineTransform(variable[, enforce_bounds])

Apply an affine transformation to a pyapprox.variables.IndependentMarginalsVariable

NatafTransform(x_marginal_cdfs, ...[, ...])

Apply the Nataf transformation to an arbitraty multivariate random variable.

RosenblattTransform(joint_density, num_vars, ...)

Apply the Rosenblatt transformation to an arbitraty multivariate random variable.

ConfigureVariableTransformation(config_values)

Class which maps one-to-one configure indices in [0, 1, 2, 3,...] to a set of configure values accepted by a function