histogram

package module
v0.0.0-...-074cc51 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2013 License: GPL-2.0 Imports: 3 Imported by: 3

README

Histogram

Pure Go (simplified) implementation of the GSL Histogram library.

For the API overview see Godoc.

See TODO for open issues.

Documentation

Index

Constants

View Source
const IntString = "%.0f %.0f %d\n"

Use IntString for the variable FormatString with ints.

Variables

View Source
var FormatString = "%f %f %v\n"

FormatString is used by the String and Scan functions for data parsing. If you want a different output, just modify the variable.

View Source
var FormatString2d = "%v %v %v %v %v\n"

FormatString2d is used by the String and Scan functions for data parsing. If you want a different output, just modify the variable.

Functions

func NaturalRange

func NaturalRange(start, size, increment uint) (res []float64)

NaturalRange generates a range of natural numbers for a new histogram. The Histogram struct works with []float64 for ranges, so this function generates []float64. Also note that the resulting range contains one extra position for the final value. For example: NaturalRange(0, 5, 10) generates []float64{0.0, 10.0, 20.0, 30.0, 40.0, 50.0}

func Range

func Range(start float64, size uint, increment float64) (res []float64)

Range generates a range of floating point numbers for a new histogram. The resulting range contains one extra position for the final value. For example: Range(0.0, 5, 0.1) generates []float64{0.0, 0.1, 0.2, 0.3, 0.4, 0.5}

Types

type Histogram

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

func NewHistogram

func NewHistogram(Range []float64) (*Histogram, error)

func (*Histogram) Add

func (h *Histogram) Add(x float64) error

func (*Histogram) Find

func (h *Histogram) Find(x float64) (int, error)

func (*Histogram) Get

func (h *Histogram) Get(i int) int

func (*Histogram) GetRange

func (h *Histogram) GetRange(i int) (lower, upper float64)

func (*Histogram) Len

func (h *Histogram) Len() int

Len returns the number of bins

func (*Histogram) Max

func (h *Histogram) Max() (max, imax int)

Max finds first value and index of max contents in bins

func (*Histogram) Mean

func (h *Histogram) Mean() float64

Mean compute the bin-weighted arithmetic mean of the histogram

func (*Histogram) Min

func (h *Histogram) Min() (min, imin int)

Min finds first value and index of min contents in bins

func (*Histogram) Sigma

func (h *Histogram) Sigma() float64

Sigma compute the bin-weighted sigma of the histogram

func (*Histogram) String

func (h *Histogram) String() (res string)

String uses the variabele FormatString for the data parsing

func (*Histogram) Sum

func (h *Histogram) Sum() (res int)

Sum up all bins of the histogram

type Histogram2d

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

func NewHistogram2d

func NewHistogram2d(xrange, yrange []float64) (*Histogram2d, error)

Routine that create a 2D histogram using the given values for X and Y ranges

func (*Histogram2d) Add

func (h *Histogram2d) Add(x, y float64) error

func (*Histogram2d) Covariance

func (h *Histogram2d) Covariance() float64

func (*Histogram2d) Find

func (h *Histogram2d) Find(x, y float64) (i, j int, err error)

func (*Histogram2d) Get

func (h *Histogram2d) Get(i, j int) int

func (*Histogram2d) GetXrange

func (h *Histogram2d) GetXrange(i int) (xlower, xupper float64)

func (*Histogram2d) GetYrange

func (h *Histogram2d) GetYrange(j int) (ylower, yupper float64)

func (*Histogram2d) LenX

func (h *Histogram2d) LenX() int

func (*Histogram2d) LenY

func (h *Histogram2d) LenY() int

func (*Histogram2d) Max

func (h *Histogram2d) Max() (xmax, ymax, imax int)

Max finds first value and index of max contents in bins

func (*Histogram2d) Min

func (h *Histogram2d) Min() (xmin, ymin, imin int)

Min finds first value and index of min contents in bins

func (*Histogram2d) String

func (h *Histogram2d) String() (res string)

String uses the variabele FormatString for the data parsing

func (*Histogram2d) Sum

func (h *Histogram2d) Sum() (sum int)

Sum up all bins of histogram2d

func (*Histogram2d) Xmean

func (h *Histogram2d) Xmean() (wmean float64)

Xmean returns the histogram arithmetic mean

func (*Histogram2d) Xsigma

func (h *Histogram2d) Xsigma() (xsigma float64)

func (*Histogram2d) Ymean

func (h *Histogram2d) Ymean() (wmean float64)

Ymean returns the histogram arithmetic mean

func (*Histogram2d) Ysigma

func (h *Histogram2d) Ysigma() (ysigma float64)

type Pdf

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

Probability distribution function

func NewPdf

func NewPdf(h *Histogram) (*Pdf, error)

func (*Pdf) Sample

func (p *Pdf) Sample(r float64) (res float64, err error)

type Pdf2d

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

func NewPdf2d

func NewPdf2d(h *Histogram2d) (p *Pdf2d, err error)

func (*Pdf2d) Sample

func (p *Pdf2d) Sample(r1, r2 float64) (x, y float64, err error)

Jump to

Keyboard shortcuts

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