Monado OpenXR Runtime
Loading...
Searching...
No Matches
math.hpp
Go to the documentation of this file.
1// Copyright 2026, Beyley Cardellio
2// SPDX-License-Identifier: BSL-1.0
3/*!
4 * @file
5 * @brief Generic math helpers for constellation optimizer code. Must not include Eigen.
6 * @author Beyley Cardellio <ep1cm1n10n123@gmail.com>
7 * @ingroup tracking
8 */
9
10#pragma once
11
12#include <cmath>
13
14
15namespace xrt::tracking::constellation::optimizer {
16
17/*
18 *
19 * Types
20 *
21 */
22
23/*!
24 * How well one kind of sensor was fit, so that a bad solve can be attributed to the sensor that could not be
25 * explained rather than guessed at from the parameter values.
26 *
27 * Both factors are whitened, so their residuals are in standard deviations and these numbers are comparable to
28 * each other and to 1. A `mean_chi_squared` far above 1 means the model cannot explain that sensor's data.
29 */
31{
32public: // Fields
33 //! How many residual rows this kind of factor contributes.
35 //! Sum of the squared whitened residuals, `2 * cost`.
37
38 //! Chi squared per residual row. Around 1 when the data matches the model and its noise model.
39 double
41 {
42 return this->num_residuals > 0 ? this->chi_squared / static_cast<double>(this->num_residuals) : 0.0;
43 }
44
45 //! The average size of a residual, in standard deviations.
46 double
47 rmsSigma() const
48 {
49 return std::sqrt(this->meanChiSquared());
50 }
51};
52
53}; // namespace xrt::tracking::constellation::optimizer
How well one kind of sensor was fit, so that a bad solve can be attributed to the sensor that could n...
Definition math.hpp:31
double rmsSigma() const
The average size of a residual, in standard deviations.
Definition math.hpp:47
double chi_squared
Sum of the squared whitened residuals, 2 * cost.
Definition math.hpp:36
size_t num_residuals
How many residual rows this kind of factor contributes.
Definition math.hpp:34
double meanChiSquared() const
Chi squared per residual row. Around 1 when the data matches the model and its noise model.
Definition math.hpp:40