6 #include <samchon/IndexPair.hpp> 35 static auto E() ->
double 47 static auto PI() ->
double 49 return 3.141592653589793;
59 static auto LN2() ->
double 61 return 1.0 / log2(
E());
71 static auto LN10() ->
double 73 return 1.0 / log10(
E());
137 static std::random_device device;
138 static std::uniform_real_distribution<double> distribution(0.0, 1.0);
140 return distribution(device);
151 return val *
PI() / 180.0;
159 return val * 180.0 /
PI();
176 template <
typename _Cont,
typename T = _Cont::value_type>
179 auto it = container.begin();
180 size_t i = 0, position = 0;
182 const T *ptr = &(*it);
184 for (; it != container.end(); it++)
193 return{ position, *ptr };
207 template <
typename _Cont,
typename T = _Cont::value_type>
210 auto it = container.begin();
211 size_t i = 0, position = 0;
213 const T *ptr = &(*it);
215 for (; it != container.end(); it++)
224 return{ position, *ptr };
238 template <
typename _Cont,
typename T = _Cont::value_type>
239 static auto mean(
const _Cont &container) ->
double 242 for (
auto it = container.begin(); it != container.end(); it++)
245 return val / (double)container.size();
259 template <
typename _Cont,
typename T = _Cont::value_type>
260 static auto median(
const _Cont &container) ->
double 262 auto it = container.begin();
264 if (container.size() % 2 == 1)
266 advance(it, container.size() / 2);
272 advance(it, container.size() / 2 - 1);
276 return ((
double)*it + (double)*next_it) / 2.0;
291 template <
typename _Cont,
typename T = _Cont::value_type>
292 static auto mode(
const _Cont &container) -> T
294 std::map<T, size_t> frequencyMap;
295 for (
auto it = container.begin(); it != container.end(); it++)
296 if (frequencyMap.find(*it) == frequencyMap.end())
297 frequencyMap[*it] = 1;
301 auto det_it = frequencyMap.begin();
302 for (
auto it = frequencyMap.begin(); it != frequencyMap.end(); it++)
303 if (it->second > det_it->second)
306 return det_it->first;
315 template <
typename _Cont,
typename T = _Cont::value_type>
316 static auto stdev_p(
const _Cont &container) ->
double 326 template <
typename _Cont,
typename T = _Cont::value_type>
327 static auto stdev_s(
const _Cont &container) ->
double 343 template <
typename _Cont,
typename T = _Cont::value_type>
349 for (
auto it = container.begin(); it != container.end(); it++)
352 return val / (double)container.size();
366 template <
typename _Cont,
typename T = _Cont::value_type>
372 for (
auto it = container.begin(); it != container.end(); it++)
375 return val / (double)(container.size() - 1);
static auto LN10() -> double
loge10
static auto stdev_s(const _Cont &container) -> double
Square root of a variance_s.
static auto PI() -> double
¥ð, Number Pi
static auto radian_to_degree(double val) -> double
Convert radian to degree.
static auto median(const _Cont &container) -> double
Get median value.
static auto LOG2E() -> double
log2e
static auto E() -> double
Exponent.
static auto LN2() -> double
loge2
static auto mode(const _Cont &container) -> T
Find mode value.
static auto SQRT1_2() -> double
Squart root of 0.5.
static auto minimum(const _Cont &container) -> IndexPair< T >
Calculate minimum value with its index.
static auto variance_s(const _Cont &container) -> double
Calculate variance for sample.
static auto SQRT2() -> double
Squart root of 2.
static auto variance_p(const _Cont &container) -> double
Calculate standard deviation for all population.
A pair of index and its value(T)
static auto maximum(const _Cont &container) -> IndexPair< T >
Calculate maximum value with its index.
static auto stdev_p(const _Cont &container) -> double
Square root of a variance_p.
static auto random() -> double
Get a random value.
static auto mean(const _Cont &container) -> double
Calculate average.
static auto degree_to_radian(double val) -> double
Convert degree to radian.
static auto LOG10E() -> double
log10e