| 
    Sample SNPs
    
   Fast ordered sampling of rows from large text or binary files. Special cases for DNA variant files (.bed, VCF, HapMap, etc). 
   | 
 
Random number generating class. More...
#include <random.hpp>
Public Member Functions | |
| RanDraw () | |
| Default constructor.  More... | |
| ~RanDraw () | |
| Destructor.  | |
| RanDraw (const RanDraw &old)=default | |
| Copy constructor.  More... | |
| RanDraw (RanDraw &&old)=default | |
| Move constructor.  More... | |
| RanDraw & | operator= (const RanDraw &old)=default | 
| Copy assignment.  More... | |
| RanDraw & | operator= (RanDraw &&old)=default | 
| Move assignment.  More... | |
| volatile uint64_t | ranInt () | 
| Generate random integer.  More... | |
| volatile double | runif () | 
| Generate a uniform deviate.  More... | |
| volatile double | runifnz () | 
| Generate a non-zero uniform deviate.  More... | |
| volatile uint64_t | vitterA (const double &n, const double &N) | 
| Sample from Vitter's distribution, method A.  More... | |
| volatile uint64_t | vitter (const double &n, const double &N) | 
| Sample from Vitter's distribution, method D.  More... | |
Random number generating class.
Generates (pseudo-)random deviates from a number of distributions. If hardware random numbers are supported, uses them. Otherwise, falls back to 64-bit MT19937 ("Mersenne Twister").
| RanDraw::RanDraw | ( | ) | 
Default constructor.
Checks if the processor provides hardware random number support. Seeds the Mersenne Twister if not. Throws "CPU_unsupported" string object if the CPU is not AMD or Intel.
      
  | 
  default | 
Copy constructor.
| [in] | old | pbject to be copied | 
      
  | 
  default | 
Move constructor.
| [in] | old | pbject to be moved | 
Copy assignment.
| [in] | old | pbject to be copied | 
Move assignment.
| [in] | old | pbject to be moved | 
      
  | 
  inline | 
Generate random integer.
      
  | 
  inline | 
Generate a uniform deviate.
| volatile double RanDraw::runifnz | ( | ) | 
Generate a non-zero uniform deviate.
| volatile uint64_t RanDraw::vitter | ( | const double & | n, | 
| const double & | N | ||
| ) | 
Sample from Vitter's distribution, method D.
Given the number of remaining records in a file \(N\) and the number of records \(n\) remaining to be selected, sample the number of records to skip over. This function implements Vitter's [2] [3] method D. It is useful for online one-pass sampling of records from a file. While the inputs are integer, we pass them in as double because that is more efficient for calculations.
| [in] | n | number of records remaining to be picked | 
| [in] | N | number of remaining records in the file | 
| volatile uint64_t RanDraw::vitterA | ( | const double & | n, | 
| const double & | N | ||
| ) | 
Sample from Vitter's distribution, method A.
Given the number of remaining records in a file \(N\) and the number of records \(n\) remaining to be selected, sample the number of records to skip over. This function implements Vitter's [2] [3] method A. It is useful for online one-pass sampling of records from a file. While the inputs are integer, we pass them in as double because that is more efficient for calculations.
| [in] | n | number of records remaining to be picked | 
| [in] | N | number of remaining records in the file |