Struct Model::CalibrationInput
Defined in File model.hpp
Nested Relationships
This struct is a nested type of Template Class Model.
Struct Documentation
-
struct CalibrationInput
Represents a calibration dataset with multi-dimensional input features, target values, and uncertainties.
This struct stores multi-dimensional input vectors (represented as arrays of size
N), target output values (y), and uncertainties (dy) associated with the output targets. The struct includes a method for checking consistency between the sizes of the input, output, and uncertainty vectors.Public Functions
-
inline bool size_consistent() const
Checks whether the sizes of the input, output, and uncertainty vectors are consistent.
Ensures that the number of input samples matches the number of target values and their uncertainties
- Returns:
True if all vectors have consistent sizes; false otherwise.
-
inline void clear()
-
inline std::pair<int, double> min_y() const
Returns the index i with minimum y[i].
-
inline void serialize(const std::string &filename) const
Serializes the contents of the CalibrationInput object to a binary file.
The function writes the size of the data followed by the raw bytes of the
x,y, anddyvectors to the specified file using binary format.- Parameters:
filename – Path to the output file.
- Throws:
std::runtime_error – if the file cannot be opened.
-
inline void deserialize(const std::string &filename)
Deserializes the contents of a CalibrationInput object from a binary file.
The function reads the binary-encoded data from the specified file and populates the
x,y, anddyvectors.- Parameters:
filename – Path to the input file.
- Throws:
std::runtime_error – if the file cannot be opened or if the read fails.
-
inline CalibrationInput subset(int sample_interval) const
Returns a sampled subset of the calibration data.
This function flattens the calibration data stored in
x,y, anddy, applies uniform downsampling based on the providedsample_interval, and then reconstructs a newCalibrationInputobject with the sampled data.- Parameters:
sample_interval – Sampling stride: every
sample_interval-th data point will be retained. Must be ≥ 1.- Returns:
A new
CalibrationInputinstance containing the sampled data.
-
inline CalibrationInput subset(std::array<double, N> x_min, std::array<double, N> x_max) const
Returns a subset of the calibration input data within a specified x-range.
This method filters the data to include only entries where the first dimension of
xlies within the interval [x_min,x_max] (inclusive). It returns a newCalibrationInputcontaining the correspondingx,y, anddyvalues.- Parameters:
x_min – The minimum value (inclusive) of the x-range filter.
x_max – The maximum value (inclusive) of the x-range filter.
- Returns:
A new
CalibrationInputobject containing only the entries withx[i]in [x_min,x_max].
-
inline void sort_by_x()
Public Members
-
std::vector<std::array<double, N>> x
Multi-dimensional input values. Each entry in the vector is an array of size
Nrepresenting a set of input features for a sample.
-
std::vector<double> y
Target output values. A vector of target values associated with each input sample.
-
std::vector<double> dy
Uncertainties associated with the target values. A vector of uncertainties (standard deviations) corresponding to the target values.
-
inline bool size_consistent() const