Loading...
Searching...
No Matches
PriorScale.h
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// Copyright (c) gpridge developers
3// See LICENSE for details.
4
5#ifndef GPR_PRIOR_PRIOR_SCALE_H_
6#define GPR_PRIOR_PRIOR_SCALE_H_
7
8#include <cmath>
9#include <stdexcept>
10#include <string>
11
12namespace gpr {
13
14// The Student-t, sqrt-t, Gaussian and log-normal densities divide by their
15// scale. A non-positive or non-finite scale is an illegal configuration,
16// not a density value: returning NaN lets a refit keep the previous length.
17inline void requirePositiveFinitePriorParameter(const char* density,
18 const char* name, double value)
19{
20 if (std::isfinite(value) && value > 0.0) return;
21 throw std::invalid_argument(std::string(density) + " " + name +
22 " must be positive and finite (got " +
23 std::to_string(value) + ")");
24}
25
26inline void requireFinitePriorParameter(const char* density, const char* name,
27 double value)
28{
29 if (std::isfinite(value)) return;
30 throw std::invalid_argument(std::string(density) + " " + name +
31 " must be finite (got " +
32 std::to_string(value) + ")");
33}
34
35} // namespace gpr
36
37#endif // GPR_PRIOR_PRIOR_SCALE_H_
Gaussian-process regression, kernels, priors, and the searches that run on the surrogate.
Definition Macros.h:16
void requirePositiveFinitePriorParameter(const char *density, const char *name, double value)
Definition PriorScale.h:17
void requireFinitePriorParameter(const char *density, const char *name, double value)
Definition PriorScale.h:26