KrisLibrary  1.0.0
Namespaces | Functions
sample.h File Reference

Functions for random sampling of various sets. More...

#include <vector>

Go to the source code of this file.

Namespaces

 Math
 Contains all definitions in the Math package.
 

Functions

int Math::WeightedSample (const std::vector< Real > &weights)
 Samples an integer with weighted probability. More...
 
int Math::WeightedSample (const std::vector< Real > &weights, Real totWeight)
 Same as above, but the sum of all weights, W, is provided.
 
int Math::CumulativeWeightedSample (const std::vector< Real > &partialSumWeights)
 
void Math::RandomAllocate (std::vector< int > &num, size_t total)
 Allocates total samples within the buckets in num, roughly evenly. An O(n) algorithm where n is the number of buckets. More...
 
void Math::RandomAllocate (std::vector< int > &num, size_t total, const std::vector< Real > &weights)
 Same as above, but with weights. More...
 
Real Math::Sample (const Interval &s)
 Uniformly samples the given intervals.
 
Real Math::Sample (const ClosedIntervalSet &s)
 Uniformly samples the interval set.
 
void Math::SampleCircle (Real r, Real &x, Real &y)
 Uniform distribution on boundary of a circle with radius r.
 
void Math::SampleDisk (Real r, Real &x, Real &y)
 Uniform distribution inside a circle with radius r.
 
void Math::SampleTriangle (Real &x, Real &y)
 Uniform distribution in the triangle whose vertices are (0,0),(1,0),(0,1)
 
void Math::SampleBall (Real r, Real &x, Real &y, Real &z)
 Uniform distribution on boundary of a sphere with radius r.
 
void Math::SampleSphere (Real r, Real &x, Real &y, Real &z)
 Uniform distribution inside a sphere with radius r.
 
void Math::SampleHyperBall (Real r, std::vector< Real > &v)
 Uniformly samples from a hyper-ball of dimension v.size()
 
void Math::SampleHyperSphere (Real r, std::vector< Real > &v)
 Uniformly samples from a hyper-sphere of dimension v.size()
 

Detailed Description

Functions for random sampling of various sets.