histo

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: LGPL-2.1 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Integrate

func Integrate(lower, upper float64, dividers ...[]float64) func(*Data) (float64, error)

func MatrixCombine

func MatrixCombine(f func(a, b, dest *Data), a, b, dest *Matrix)

Combines 2 matrices element-wise using the function f, which should take 2 histograms to be combined and one more where the result of the operation is stored.

func Mean

func Mean(dividers ...[]float64) func(*Data) (float64, error)

func Quantile

func Quantile(nquant float64, dividers ...[]float64) func(*Data) (float64, error)

returns the nquant quartile of the histogram. nquant is a float between 0 and 1

func StatFunc

func StatFunc(f func(x, w []float64) float64, dividers ...[]float64) func(*Data) (float64, error)

returns the results of the function f which takes a set of values and their weights (in this case, the values are the mean of the 2 limits of each histogram bin, and the weights are the value for that bin.

func StdDev

func StdDev(dividers ...[]float64) func(*Data) (float64, error)

Types

type Data

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

func NewData

func NewData(dividers []float64, rawdata []float64, ID ...int) *Data

Returns a new histogram from the dividers and rawdata given rawdata can be nil. In that case, an empty histogram is created. if an ID for the histogram is given, it will be set. If not, the ID will be set to -1.

func (*Data) Add

func (D *Data) Add(a, b *Data)

Add adds the histograms a and b putting the result in the receiver.

func (*Data) AddData

func (M *Data) AddData(point ...float64)

Adds the given data point(s) to the histogram

func (*Data) Copy

func (D *Data) Copy(dest ...[]float64) []float64

func (*Data) CopyDividers

func (D *Data) CopyDividers(dest ...[]float64) []float64

Copies the dividers of the histogram

func (*Data) ID

func (D *Data) ID() int

ID returns the ID of the histogram

func (*Data) MarshalJSON

func (D *Data) MarshalJSON() ([]byte, error)

func (*Data) Normalize

func (D *Data) Normalize()

Normalize normalizes the histogram

func (*Data) Normalized

func (D *Data) Normalized() bool

Normalized Returns true if the histogram is normalized

func (*Data) ReHisto

func (D *Data) ReHisto(dividers, rawdata []float64)

func (*Data) String

func (D *Data) String() string

String prints a -hopefully- pretty string representation of the histogram. The representation uses 3 lines of thext

func (*Data) Sub

func (D *Data) Sub(a, b *Data, abs ...bool)

Sub substract the histograms a and b puting the results in the receiver if abs is given and true (only the first element is considered)

func (*Data) Sum

func (D *Data) Sum() float64

func (*Data) UnNormalize

func (D *Data) UnNormalize()

UnNormalize un-normalizes the histogram

func (*Data) UnmarshalJSON

func (D *Data) UnmarshalJSON(b []byte) error

func (*Data) View

func (D *Data) View() []float64

type Matrix

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

A matrix of histograms

func NewMatrix

func NewMatrix(r, c int, dividers []float64) *Matrix

NewMatrix returns a new matrix of *Data with r and c rows and column and dividers dividers. Dividers can be nil, in which case, elements of the matrix will not be forced to have the same dividers

func (*Matrix) AddData

func (M *Matrix) AddData(r, c int, point ...float64)

Adds one or more data points to the histogram in the r,c position in the matrix

func (*Matrix) AddDataCS

func (M *Matrix) AddDataCS(r, c int, point ...float64)

Adds one or more data points to the histogram in the r,c position in the matrix it is concurrent safe

func (*Matrix) Check

func (M *Matrix) Check(r, c int, pan ...bool) error

Check checks if the given row and column indexes are within range. if pan is given and true, it panics if either is out of range, otherwise, it returns an error.

func (*Matrix) CopyDividers

func (M *Matrix) CopyDividers(dest ...[]float64) []float64

Copies the dividers of the histogram

func (*Matrix) Dims

func (M *Matrix) Dims() (int, int)

func (*Matrix) Fill

func (M *Matrix) Fill()

Fill fills the matrix with empty histograms If the matrix has a non-nil delimiters slice, that slice is used for all the histograms created

func (*Matrix) FromAll

func (M *Matrix) FromAll(f func(D *Data) (float64, error)) ([][]float64, error)

Applies the f function to each element in the matrix, the results are returned as a [][]float64. Also returns error unpon failure, or nil.

func (*Matrix) MarshalJSON

func (M *Matrix) MarshalJSON() ([]byte, error)

func (*Matrix) NewHisto

func (M *Matrix) NewHisto(r, c int, dividers []float64, rawdata []float64, ID ...int)

NewHisto Puts a new histogram in the r,c position in the matrix. Dividers can be nil, in which case, the matrix should have its dividers. If there are no dividers, or they don't match, the function will panic. rawdata can also be nil, in which case, an empty histogram will be put in the position.

func (*Matrix) NormalizeAll

func (M *Matrix) NormalizeAll()

Normalize all the histograms in the matrix

func (*Matrix) String

func (M *Matrix) String() string

func (*Matrix) ToAll

func (M *Matrix) ToAll(f func(D *Data) error) error

Applies the f function to each element in the matrix. Returns error unpon failure, or nil.

func (*Matrix) UnNormalizeAll

func (M *Matrix) UnNormalizeAll()

Un-normalize all the histograms in the matrix

func (*Matrix) UnmarshalJSON

func (M *Matrix) UnmarshalJSON(b []byte) error

func (*Matrix) View

func (M *Matrix) View(r, c int) *Data

View Returns a view of the histogram in the r,c position in the matrix

Jump to

Keyboard shortcuts

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