Program Listing for File RandomNumbers.h
↰ Return to documentation for file (ADS/numeric/RandomNumbers.h)
/*--------------------------------------------------------------------------*/
/*-------------------------- File RandomNumbers.h --------------------------*/
/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
/*----------------------------- DEFINITIONS --------------------------------*/
/*--------------------------------------------------------------------------*/
#ifndef __ADS_RandomNumbers
#define __ADS_RandomNumbers
/* self-identification: #endif constant */
/*--------------------------------------------------------------------------*/
/*------------------------------ INCLUDES ----------------------------------*/
/*--------------------------------------------------------------------------*/
#include "ADS/Contract.h"
#include "ADS/numeric/NumberTheory.h"
#include <algorithm>
#include <cmath>
#include <cstddef>
#include <cstdint>
#include <limits>
#include <random>
#include <utility>
#include <vector>
/*--------------------------------------------------------------------------*/
/*--------------------------- NAMESPACE ------------------------------------*/
/*--------------------------------------------------------------------------*/
namespace ADS {
/*--------------------------------------------------------------------------*/
/*------------------------ CLASS LinearCongruential ------------------------*/
/*--------------------------------------------------------------------------*/
class LinearCongruential {
public:
using result_type = std::uint64_t;
LinearCongruential( std::uint64_t a , std::uint64_t c , std::uint64_t m ,
std::uint64_t seed );
static LinearCongruential minstd( std::uint64_t seed = 1 );
static LinearCongruential mmix( std::uint64_t seed = 1 );
std::uint64_t operator()( void );
[[nodiscard]] std::uint64_t min( void ) const { return( 0 ); }
[[nodiscard]] std::uint64_t max( void ) const {
return( f_m ? f_m - 1 : std::numeric_limits< std::uint64_t >::max() );
}
[[nodiscard]] std::uint64_t period( std::uint64_t limit ) const;
private:
std::uint64_t f_a , f_c , f_m , f_x;
};
inline double chiSquare( const std::vector< long > & Y ,
const std::vector< double > & p );
inline std::pair< double , double > kolmogorovSmirnov(
std::vector< double > U );
inline double serialTest( const std::vector< double > & U , int d );
inline double spectralTest2( std::uint64_t a , std::uint64_t m );
template< class T , class R >
void shuffle( std::vector< T > & A , R & g );
template< class R >
std::vector< std::size_t > selectionSampling( std::size_t n , std::size_t N ,
R & g );
template< class T , class R >
std::vector< T > reservoirSampling( const std::vector< T > & S ,
std::size_t n , R & g );
/*--------------------------------------------------------------------------*/
} // end( namespace ADS )
/*--------------------------------------------------------------------------*/
/*-------------------------- IMPLEMENTATION --------------------------------*/
/*--------------------------------------------------------------------------*/
#include "ADS/numeric/impl/RandomNumbers.tpp"
/*--------------------------------------------------------------------------*/
#endif /* RandomNumbers.h included */
/*--------------------------------------------------------------------------*/
/*------------------------ End File RandomNumbers.h ------------------------*/
/*--------------------------------------------------------------------------*/