Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func String ¶
String returns a random string with the given length (<=32), from a set of possible strings of size "cardinality".
Types ¶
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator holds state for generating random data in certain distributions.
func (*Generator) String ¶
String gets a zipfian random string from a set with the given cardinality.
type PermutationGenerator ¶
type PermutationGenerator struct {
// contains filtered or unexported fields
}
PermutationGenerator provides a way to pass integer IDs through a permutation map that is pseudorandom but repeatable. This could be done with rand.Perm, but that would require storing a [Iterations]int64 array, which we want to avoid for large values of Iterations. It works by using a Linear Congruence Generator (https://en.wikipedia.org/wiki/Linear_congruential_generator) with modulus m = Iterations, c = an arbitrary prime, a = computed to ensure the full period. relevant stackoverflow: http://cs.stackexchange.com/questions/29822/lazily-computing-a-random-permutation-of-the-positive-integers
func NewPermutationGenerator ¶
func NewPermutationGenerator(m int64, seed int64) *PermutationGenerator
NewPermutationGenerator returns a PermutationGenerator which will permute numbers in 0-n.
func (*PermutationGenerator) Permute ¶
func (p *PermutationGenerator) Permute(n int64) int64
Permute gets the permuted value for n.