sample

package
v0.0.0-...-0da26dc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 25, 2022 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package sample includes the functionality for sampling from a discrete distribution.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DiscreteDistribution

type DiscreteDistribution struct {
	WeightedValues []WeightedValue
}

DiscreteDistribution represents a collection of weighted values that form a distribution.

func (DiscreteDistribution) Random

func (d DiscreteDistribution) Random() interface{}

Random samples the DiscreteDistribution and returns the resulting value.

type WeightedValue

type WeightedValue struct {
	Value     interface{}
	Frequency uint
}

WeightedValue represents the value and its frequency.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL