Source code for neural_operators.mcmc.state

# SPDX-FileCopyrightText: 2026 Prashant K. Jha
# SPDX-License-Identifier: GPL-3.0-or-later
#
# Part of the neural_operators library.
# https://github.com/CEADpx/neural_operators
#
# If you use this software, please cite:
#   P. K. Jha, From theory to application: A practical introduction to neural
#   operators in scientific computing, Mathematics 14(13), 2421, 2026.
#   https://doi.org/10.3390/math14132421

import numpy as np

[docs] class State: """A single MCMC state: m/u plus the quantities derived from them (observations, errors, log-likelihood/prior/posterior, cost).""" def __init__(self, m_dim, u_dim, u_obs_dim): self.m = np.zeros(m_dim) self.u = np.zeros(u_dim) self.u_obs_dim = u_obs_dim self.u_obs = np.zeros(u_obs_dim) self.err_obs = np.zeros(u_obs_dim) self.log_likelihood = 0 self.log_posterior = 0 self.log_prior = 0 self.cost = 0
[docs] def set(self, a): self.m = a.m.copy() self.u = a.u.copy() self.u_obs = a.u_obs.copy() self.err_obs = a.err_obs.copy() self.log_likelihood = a.log_likelihood self.log_posterior = a.log_posterior self.log_prior = a.log_prior self.cost = a.cost