65 template<
typename dtype>
73 if (inPercentile < 0. || inPercentile > 100.)
108 const auto indexLower = clip<uint32>(i, 0, inArray.
size() - 2);
110 switch (inInterpMethod)
114 const double percentI =
115 static_cast<double>(indexLower) /
static_cast<double>(inArray.
size() - 1);
116 const double fraction =
117 (inPercentile / 100. - percentI) /
118 (
static_cast<double>(indexLower + 1) /
static_cast<double>(inArray.
size() - 1) - percentI);
121 arrayCopy[indexLower] + (arrayCopy[indexLower + 1] - arrayCopy[indexLower]) * fraction
137 const double percent = inPercentile / 100.;
138 const double percent1 =
139 static_cast<double>(indexLower) /
static_cast<double>(inArray.
size() - 1);
140 const double percent2 =
141 static_cast<double>(indexLower + 1) /
static_cast<double>(inArray.
size() - 1);
142 const double diff1 = percent - percent1;
143 const double diff2 = percent2 - percent;
145 switch (argmin<double>({ diff1, diff2 }).item())
163 NdArray<double> returnArray = { (arrayCopy[indexLower] + arrayCopy[indexLower + 1]) / 2. };
178 for (
uint32 row = 0; row < inShape.
rows; ++row)
#define THROW_INVALID_ARGUMENT_ERROR(msg)
Definition: Error.hpp:37
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition: StaticAsserts.hpp:39
size_type size() const noexcept
Definition: NdArrayCore.hpp:4524
iterator end() noexcept
Definition: NdArrayCore.hpp:1623
typename AllocTraits::pointer pointer
Definition: NdArrayCore.hpp:152
self_type transpose() const
Definition: NdArrayCore.hpp:4882
bool isempty() const noexcept
Definition: NdArrayCore.hpp:2932
const Shape & shape() const noexcept
Definition: NdArrayCore.hpp:4511
const_reference back() const noexcept
Definition: NdArrayCore.hpp:2287
const_reference front() const noexcept
Definition: NdArrayCore.hpp:2860
iterator begin() noexcept
Definition: NdArrayCore.hpp:1315
bool isscalar() const noexcept
Definition: NdArrayCore.hpp:2956
value_type item() const
Definition: NdArrayCore.hpp:3022
A Shape Class for NdArrays.
Definition: Core/Shape.hpp:41
uint32 rows
Definition: Core/Shape.hpp:44
uint32 cols
Definition: Core/Shape.hpp:45
void sort(RandomIt first, RandomIt last) noexcept
Definition: StlAlgorithms.hpp:696
bool essentiallyEqual(dtype inValue1, dtype inValue2) noexcept
Definition: essentiallyEqual.hpp:49
Definition: Cartesian.hpp:40
InterpolationMethod
Definition: Enums.hpp:139
Axis
Enum To describe an axis.
Definition: Enums.hpp:36
dtype floor(dtype inValue) noexcept
Definition: floor.hpp:48
NdArray< double > percentile(const NdArray< dtype > &inArray, double inPercentile, Axis inAxis=Axis::NONE, InterpolationMethod inInterpMethod=InterpolationMethod::LINEAR)
Definition: percentile.hpp:66
std::uint32_t uint32
Definition: Types.hpp:40