crawlserv++  [under development]
Application for crawling and analyzing textual content of websites.
crawlservpp::Helper::Math Namespace Reference

Namespace for global math functions. More...

Mean, Median, and Standard Derivation

template<typename R , typename T , template< typename, typename > class Container>
avg (const Container< T, std::allocator< T >> &values)
 
template<typename R , typename T , template< typename, typename > class Container>
median (Container< T, std::allocator< T >> &values)
 
template<typename R , typename T , template< typename, typename > class Container>
variance (R mean, Container< T, std::allocator< T >> &values)
 Calculates the variance from the given mean of all elements in the given container. More...
 
template<typename R , typename T , template< typename, typename > class Container>
variance (Container< T, std::allocator< T >> &values)
 

Floating-Point Number Comparison

template<typename T >
std::enable_if<!std::numeric_limits< T >::is_integer, bool >::type almostEqual (T x, T y, int ulp)
 Compares two floating-point values using epsilon. More...
 

Detailed Description

Namespace for global math functions.

Function Documentation

◆ almostEqual()

template<typename T >
std::enable_if<!std::numeric_limits<T>::is_integer, bool>::type crawlservpp::Helper::Math::almostEqual ( x,
y,
int  ulp 
)

Compares two floating-point values using epsilon.

Original: https://en.cppreference.com/w/cpp/types/numeric_limits/epsilon

Parameters
x,yFloating-point numbers to compare.
ulpDesired precision in ULPs (units in the last place).

Referenced by crawlservpp::Module::Analyzer::Algo::TopicModelling::resetAlgo().

◆ avg()

template<typename R , typename T , template< typename, typename > class Container>
R crawlservpp::Helper::Math::avg ( const Container< T, std::allocator< T >> &  values)

Calculates the average (mean) of all elements in the given container.

Parameters
valuesConstant reference to the container.
Returns
The average of all elements in the given container

Referenced by variance().

◆ median()

template<typename R , typename T , template< typename, typename > class Container>
R crawlservpp::Helper::Math::median ( Container< T, std::allocator< T >> &  values)

Calculates the median of all elements in the given container.

Parameters
valuesReference to the container.
Returns
The median of all elements in the given container.

◆ variance() [1/2]

template<typename R , typename T , template< typename, typename > class Container>
R crawlservpp::Helper::Math::variance ( mean,
Container< T, std::allocator< T >> &  values 
)

Calculates the variance from the given mean of all elements in the given container.

Parameters
meanMean of all elements in the container.
valuesReference to the container.
Returns
The variance, i.e. the squared standard deviation, from the given mean of all elements in the given container.

Referenced by variance().

◆ variance() [2/2]

template<typename R , typename T , template< typename, typename > class Container>
R crawlservpp::Helper::Math::variance ( Container< T, std::allocator< T >> &  values)

Calculates the variance of all elements in the given container.

Parameters
valuesReference to the container.
Returns
The variance, i.e. the squared standard deviation, from the mean of all elements in the given container.

References avg(), and variance().