### High-Level Example Usage Source: https://github.com/romeov/probabilisticparameterestimators.jl/blob/master/README.md Demonstrates how to use the ProbabilisticParameterEstimators.jl library for parameter estimation. It shows setting up an observation function, true parameters, prior beliefs, noise models, and then using different estimators (MCMCEstimator, LinearApproxEstimator, LSQEstimator) to predict parameter samples or distributions. ```julia using Distributions using LinearAlgebra using ProbabilisticParameterEstimators # observation function with multivariate observations f(x, p) = [(x + 1)^2 - sum(p); (x + 1)^3 + diff(p)[1]] # true parameter (to be estimated) and a prior belief thtrue = [1.0, 2.0] paramprior = MvNormal(zeros(2), 4.0 * I) # observation noise xs = rand(5) obsnoises = [rand()/10 * I(2) * MvNormal(zeros(2), I) for _ in eachindex(xs)] noisemodel = UncorrGaussianNoiseModel(obsnoises) # noisy observations x and y ysmeas = f.(xs, [θtrue]) .+ rand.(obsnoises) # find a probabilistic description of θ either as samples or as a distribution # currently we provide three methods for est in [MCMCEstimator(), LinearApproxEstimator(), LSQEstimator()] # either samples = predictsamples(est, f, xs, ysmeas, paramprior, noisemodel, 100) # or dist = predictdist(est, f, xs, ysmeas, paramprior, noisemodel; nsamples=100) end ``` -------------------------------- ### Uncorrelated Product Noise Model Example Source: https://github.com/romeov/probabilisticparameterestimators.jl/blob/master/docs/src/noisemodels.md Illustrates the use of the UncorrProductNoiseModel for univariate noise with arbitrary distributions. The example sets up a model with truncated normal distributions and generates noisy measurements. ```julia ## UncorrProductNoiseModel xs = eachcol(rand(2,30)) # one univariate distribution per observation productnoise = [truncated(0.1*Normal(), 0, Inf) for _ in 1:length(xs)] noisemodel = UncorrProductNoiseModel(productnoise) θtrue = [5., 10] ysmeas = f.(xs, [θtrue]) .+ rand.(productnoise) ``` -------------------------------- ### Uncorrelated Gaussian Noise Model Example Source: https://github.com/romeov/probabilisticparameterestimators.jl/blob/master/docs/src/noisemodels.md Demonstrates the usage of the UncorrGaussianNoiseModel with multivariate Gaussian noise. It shows how to create the model with a list of normal distributions and generate measurements with added noise. ```julia ## UncorrGaussianNoiseModel xs = rand(5) # one (uni- or multivariate) normal distribution per observation noises = [MvNormal(zeros(2), I) for _ in eachindex(xs)] noisemodel = UncorrGaussianNoiseModel(noises) θtrue = [1.0, 2.0] ysmeas = f.(xs, [θtrue]) .+ rand.(noises) ``` -------------------------------- ### CorrGaussianNoiseModel Example Source: https://github.com/romeov/probabilisticparameterestimators.jl/blob/master/README.md Shows an example of CorrGaussianNoiseModel, used when there is correlation between observations. It employs a single multivariate normal distribution for all observations, flattening multivariate observations to match the noise model. ```julia using Distributions using LinearAlgebra # Assuming CorrGaussianNoiseModel is defined elsewhere xs = 5 * eachcol(rand(2,30)) n = length(xs) # one large Gaussian relating all observations corrnoise = MvNormal(zeros(n), I(n) + 1/5*hermitianpart(rand(n, n))) noisemodel = CorrGaussianNoiseModel(corrnoise) θtrue = [5., 10] ysmeas = f.(xs, [θtrue]) .+ rand(corrnoise) ``` -------------------------------- ### Correlated Gaussian Noise Model Example Source: https://github.com/romeov/probabilisticparameterestimators.jl/blob/master/docs/src/noisemodels.md Shows how to implement the CorrGaussianNoiseModel for correlated observations using a single multivariate normal distribution. The example constructs a correlated noise distribution and generates measurements. ```julia ## CorrGaussianNoiseModel xs = 5 * eachcol(rand(2,30)) n = length(xs) # one large Gaussian relating all observations corrnoise = MvNormal(zeros(n), I(n) + 1/5*hermitianpart(rand(n, n))) noisemodel = CorrGaussianNoiseModel(corrnoise) θtrue = [5., 10] ysmeas = f.(xs, [θtrue]) .+ rand(corrnoise) ``` -------------------------------- ### UncorrProductNoiseModel Example Source: https://github.com/romeov/probabilisticparameterestimators.jl/blob/master/README.md Demonstrates the UncorrProductNoiseModel, which handles uncorrelated univariate noise distributions for each observation. This model cannot model correlations within a single observation. ```julia using Distributions # Assuming UncorrProductNoiseModel is defined elsewhere xs = eachcol(rand(2,30)) # one univariate distribution per observation productnoise = [truncated(0.1*Normal(), 0, Inf) for _ in 1:length(xs)] noisemodel = UncorrProductNoiseModel(productnoise) θtrue = [5., 10] # Assuming f is a defined function ysmeas = f.(xs, [θtrue]) .+ rand.(productnoise) ``` -------------------------------- ### High-Level Example of Probabilistic Parameter Estimation in Julia Source: https://github.com/romeov/probabilisticparameterestimators.jl/blob/master/docs/src/index.md Demonstrates how to use ProbabilisticParameterEstimators.jl for parameter estimation. It defines an observation function, true parameters, prior beliefs, noise models, and then uses different estimators (MCMCEstimator, LinearApproxEstimator, LSQEstimator) to predict parameter samples or distributions from noisy observations. ```julia using Distributions using LinearAlgebra using ProbabilisticParameterEstimators # observation function with multivariate observations f(x, p) = [(x + 1)^2 - sum(p); (x + 1)^3 + diff(p)[1]] # true parameter (to be estimated) and a prior belief θtrue = [1.0, 2.0] paramprior = MvNormal(zeros(2), 4.0 * I) # observation noise xs = rand(5) noises = [rand()/10 * I(2) for _ in eachindex(xs)] noisemodel = UncorrGaussianNoiseModel(noises) # noisy observations x and y ysmeas = f.(xs, [θtrue]) .+ rand.(MvNormal.(zeros(2), noises)) # find a probabilistic description of θ either as samples or as a distribution # currently we provide three methods for est in [MCMCEstimator(), LinearApproxEstimator(), LSQEstimator()] # either samples = predictsamples(est, f, xs, ysmeas, paramprior, noisemodel, 100) # or dist = predictdist(est, f, xs, ysmeas, paramprior, noisemodel; nsamples=100) end ``` -------------------------------- ### UncorrGaussianNoiseModel Example Source: https://github.com/romeov/probabilisticparameterestimators.jl/blob/master/README.md Illustrates the creation and usage of UncorrGaussianNoiseModel. This model is suitable when there is no correlation between multiple observations, with each observation having its own (possibly multivariate) Gaussian noise distribution. ```julia using Distributions using LinearAlgebra # Assuming MvNormal and UncorrGaussianNoiseModel are defined elsewhere xs = rand(5) # one (uni- or multivariate) normal distribution per observation noises = [MvNormal(zeros(2), I) for _ in eachindex(xs)] noisemodel = UncorrGaussianNoiseModel(noises) θtrue = [1.0, 2.0] # Assuming f is a defined function ysmeas = f.(xs, [θtrue]) .+ rand.(noises) ``` -------------------------------- ### Utility Function Documentation Source: https://github.com/romeov/probabilisticparameterestimators.jl/blob/master/docs/src/noisemodels.md Provides documentation links for utility functions related to noise modeling. ```APIDOC mvnoisedistribution covmatrix ``` -------------------------------- ### Noise Model Documentation Source: https://github.com/romeov/probabilisticparameterestimators.jl/blob/master/docs/src/noisemodels.md Provides documentation links for the core noise model types in the ProbabilisticParameterEstimators package. ```APIDOC ProbabilisticParameterEstimators.NoiseModel UncorrGaussianNoiseModel UncorrProductNoiseModel CorrGaussianNoiseModel ``` -------------------------------- ### LinearApproxEstimator Usage Source: https://github.com/romeov/probabilisticparameterestimators.jl/blob/master/README.md Demonstrates the usage of LinearApproxEstimator for predicting distributions and samples. It highlights the efficiency of solving one optimization problem and computing one Jacobian for MvNormal creation. ```julia predictdist(::LinearApproxEstimator, f, xs, ys, paramprior, noisemodel, nsamples) predictsamples(::LinearApproxEstimator, f, xs, ys, paramprior, noisemodel, nsamples) ``` -------------------------------- ### MCMCEstimator Usage Source: https://github.com/romeov/probabilisticparameterestimators.jl/blob/master/README.md Details the usage of the MCMCEstimator, which frames the parameter estimation problem as a Markov-Chain Monte-Carlo inference problem solved using the NUTS algorithm from Turing.jl. It explains how `predictdist` generates samples and optionally fits a MvNormal distribution. ```julia # predictdist(::MCMCEstimator, f, xs, ys, paramprior, noisemodel, nsamples) # will create nsamples samples (after skipping warmup steps). # predictdist(::MCMCEstimator, f, xs, ys, paramprior, noisemodel, nsamples) # will do the same, and then fit a MvNormal distribution. ``` -------------------------------- ### Predicting Samples Source: https://github.com/romeov/probabilisticparameterestimators.jl/blob/master/docs/src/estimators.md Generates probabilistic predictions as a set of samples. This is useful for Monte Carlo methods or when a distributional representation is not required. ```APIDOC ProbabilisticParameterEstimators.predictsamples predictsamples(method::EstimationMethod, data::AbstractArray{<:Real}, obs_noise::Real) Generates probabilistic predictions as samples. Parameters: method: The estimation method used (e.g., LSQEstimator, LinearApproxEstimator, MCMCEstimator). data: The observed data. obs_noise: The noise level of the observations. ``` -------------------------------- ### LSQEstimator Usage Source: https://github.com/romeov/probabilisticparameterestimators.jl/blob/master/README.md Explains the LSQEstimator, which estimates parameters by repeatedly solving a least-squares problem with modified observations. It details how noise is sampled from the noise model and how weights are determined for uncorrelated and correlated noise. It also clarifies the role of `paramprior` and the output of `predictsamples` and `predictdist`. ```julia # The LSQEstimator works by sampling noise ε⁽ᵏ⁾ from the noise model and repeatedly solving a least-squares parameter estimation problem for modified observations y - ε⁽ᵏ⁾, i.e. # θ = arg min_θ Σᵢ ((yᵢ - εᵢ⁽ᵏ⁾) - f(xᵢ, θ))² ⋅ wᵢ # for uncorrelated noise, where the weights wᵢ are chosen as the inverse variance. # For correlated noise, the weight results from the whole covariance matrix. # The paramprior is used to sample initial guesses for θ. # Therefore predictsamples(::LSQEstimator, f, xs, ys, paramprior, noisemodel, nsamples) will solve nsamples optimization problems and return a sample each. # predictdist(::LSQEstimator, f, xs, ys, paramprior, noisemodel, nsamples) will do the same, and then fit a MvNormal distribution. ``` -------------------------------- ### Estimation Method Base Type Source: https://github.com/romeov/probabilisticparameterestimators.jl/blob/master/docs/src/estimators.md Defines the abstract base type for all estimation methods. This serves as a common interface for different estimation strategies. ```APIDOC ProbabilisticParameterEstimators.EstimationMethod EstimationMethod Abstract base type for all estimation methods. Concrete estimators like LSQEstimator, LinearApproxEstimator, and MCMCEstimator must subtype this. ``` -------------------------------- ### MCMC Estimator Source: https://github.com/romeov/probabilisticparameterestimators.jl/blob/master/docs/src/estimators.md Implements estimation using Markov Chain Monte Carlo (MCMC) methods. MCMC is powerful for complex probability distributions and Bayesian inference. ```APIDOC MCMCEstimator MCMCEstimator() MCMC Estimator. Initializes the MCMCEstimator. ``` -------------------------------- ### Linear Approximation Estimator Source: https://github.com/romeov/probabilisticparameterestimators.jl/blob/master/docs/src/estimators.md Implements estimation using linear approximation. This method is suitable when the relationship between parameters and observations can be approximated linearly. ```APIDOC LinearApproxEstimator LinearApproxEstimator() Linear Approximation Estimator. Initializes the LinearApproxEstimator. ``` -------------------------------- ### Predicting Distributions Source: https://github.com/romeov/probabilisticparameterestimators.jl/blob/master/docs/src/estimators.md Generates probabilistic predictions as a distribution. This function is part of the core prediction capabilities of the parameter estimators. ```APIDOC ProbabilisticParameterEstimators.predictdist predictdist(method::EstimationMethod, data::AbstractArray{<:Real}, obs_noise::Real) Generates probabilistic predictions as a distribution. Parameters: method: The estimation method used (e.g., LSQEstimator, LinearApproxEstimator, MCMCEstimator). data: The observed data. obs_noise: The noise level of the observations. ``` -------------------------------- ### Least Squares Estimator Source: https://github.com/romeov/probabilisticparameterestimators.jl/blob/master/docs/src/estimators.md Implements the Least Squares estimation method. This is a common technique for finding the best fit parameters by minimizing the sum of the squares of the residuals. ```APIDOC LSQEstimator LSQEstimator() Least Squares Estimator. Initializes the LSQEstimator. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.