include/terraingen/distribution/log_polynomial.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // SPDX-License-Identifier: BSD-3-Clause | ||
| 2 | |||
| 3 | /// @file | ||
| 4 | /// @brief Size-frequency distributions given by a polynomial in log diameter. | ||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include "terraingen/distribution/size_frequency.h" | ||
| 8 | |||
| 9 | #include <vector> | ||
| 10 | |||
| 11 | namespace terraingen { | ||
| 12 | |||
| 13 | /// N(>=D) = 10^P(x) / `areaUnit` with P(x) = sum_i a_i x^i and x = log10(D / | ||
| 14 | /// `diameterUnit`), the form of the Neukum et al. (2001) production function. | ||
| 15 | 1555 | class LogPolynomialSfd final : public SizeFrequencyDistribution { | |
| 16 | public: | ||
| 17 | /// The distribution with the given coefficients and units. | ||
| 18 | /// @param coefficients a_0, a_1, ... in increasing degree; at least one, all finite. | ||
| 19 | /// @param range Diameters in meters with 0 < `min` and finite `max`. | ||
| 20 | /// @param diameterUnit Meters per unit of D in the fit; 1000 for coefficients in km. | ||
| 21 | /// @param areaUnit m^2 per unit of area in the fit; 1e6 for counts per km^2. | ||
| 22 | /// @throws std::invalid_argument for a bad parameter or an N(>=D) that increases in the range. | ||
| 23 | LogPolynomialSfd(std::vector<double> coefficients, SfdKind kind, DiameterRange range, | ||
| 24 | double diameterUnit = 1.0, double areaUnit = 1.0); | ||
| 25 | |||
| 26 | /// The coefficients a_0, a_1, ... in increasing degree. | ||
| 27 | 1 | const std::vector<double>& Coefficients() const { | |
| 28 | 1 | return m_coefficients; | |
| 29 | } | ||
| 30 | |||
| 31 | protected: | ||
| 32 | double CumulativeAt(double diameter) const override; | ||
| 33 | double IncrementalAt(double diameter) const override; | ||
| 34 | |||
| 35 | private: | ||
| 36 | double Polynomial(double x) const; | ||
| 37 | double Derivative(double x) const; | ||
| 38 | |||
| 39 | std::vector<double> m_coefficients; | ||
| 40 | double m_diameterUnit; | ||
| 41 | double m_areaUnit; | ||
| 42 | }; | ||
| 43 | |||
| 44 | } // namespace terraingen | ||
| 45 |