numerics 0.1.0
Loading...
Searching...
No Matches
boltzmann_table.hpp
Go to the documentation of this file.
1/// @file stochastic/boltzmann_table.hpp
2/// @brief Boltzmann acceptance probability helpers for Metropolis MCMC.
3#pragma once
4
5#include <cmath>
6#include <vector>
7
8namespace num::markov {
9
10inline double boltzmann_accept(double dE, double beta) noexcept {
11 return (dE <= 0.0) ? 1.0 : std::exp(-beta * dE);
12}
13
14inline std::vector<double> make_boltzmann_table(const std::vector<double>& dEs,
15 double beta) {
16 std::vector<double> table(dEs.size());
17 for (std::size_t i = 0; i < dEs.size(); ++i)
18 table[i] = boltzmann_accept(dEs[i], beta);
19 return table;
20}
21
22} // namespace num::markov
std::vector< double > make_boltzmann_table(const std::vector< double > &dEs, double beta)
double boltzmann_accept(double dE, double beta) noexcept
real beta(real a, real b)
B(a, b) – beta function.
Definition math.hpp:248