math

package
v0.0.0-...-c8a214a Latest Latest
Warning

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

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

Documentation

Overview

Package math provides mathematical utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Round

func Round(f float64) int64

Round computes the nearest integer to f, rounding ties towards positive infinity.

func Sign

func Sign(f float64) int

Sign returns -1 if f is negative, +1 if f is positive, and 0 if f is positive or negative zero or NaN.

func SignInt64

func SignInt64(i int64) int

SignInt64 returns -1 if f is negative, +1 if f is positive, and 0 if f is 0.

Types

type ExponentialDistribution

type ExponentialDistribution float64

ExponentialDistribution represents an exponential distribution with a given mean.

func NewExponentialDistribution

func NewExponentialDistribution(mean float64) ExponentialDistribution

NewExponentialDistribution creates an ExponentialDistribution with the given mean.

func (ExponentialDistribution) CumulativeProbability

func (mean ExponentialDistribution) CumulativeProbability(x float64) float64

CumulativeProbability returns P(X < x) for this distribution. Based on http://mathworld.wolfram.com/ExponentialDistribution.html

func (ExponentialDistribution) InverseCumulativeProbability

func (mean ExponentialDistribution) InverseCumulativeProbability(p float64) (float64, error)

InverseCumulativeProbability returns the critical point x, such that P(X < x) = p.

type PoissonDistribution

type PoissonDistribution struct {
	// contains filtered or unexported fields
}

PoissonDistribution models the number of times an event occurs in an interval of time. It produces a sequence of time.Duration values that represent the delay between the events for an average rate.

func NewPoissonDistribution

func NewPoissonDistribution(rate float64) (*PoissonDistribution, error)

NewPoissonDistribution creates a new new PoissonDistribution with the given average rate. The rate must be greater than 0.

The PoissonDistribution created by this function contains a random number source that is not safe for concurrent use (see math/rand.NewSource).

func NewPoissonDistributionWithRand

func NewPoissonDistributionWithRand(rate float64, rng *rand.Rand) (*PoissonDistribution, error)

NewPoissonDistributionWithRand creates a new PoissonDistribution with the given average rate and random number generator. The rate must be greater than 0.

func (*PoissonDistribution) Next

func (p *PoissonDistribution) Next() time.Duration

Next generates the next delay in the sequence.

Jump to

Keyboard shortcuts

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