stats

package
v0.0.0-...-b26d460 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package stats provides a wrapper around github.com/montanaflynn/stats to compute common statistics for a dataset.

The package requires the dataset to be a slice of float64. The caller has the responsibility of transforming the data into a usable dataset for stats.Compute.

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptySlice = errors.New("input slice is empty")

ErrEmptySlice is returned when working on an empty slice.

Functions

This section is empty.

Types

type Common

type Common struct {
	Min    float64
	Max    float64
	Mean   float64
	Median float64
	StdDev float64

	// Deciles is an array composed of the nine deciles.
	// Deciles[0] is the first decile (10%), Deciles[8]
	// is the 9th decile (90%).
	Deciles [9]float64
}

Common represents the common statistics computed from a given dataset.

func ComputeCommon

func ComputeCommon(data []float64) (Common, error)

ComputeCommon computes the common statistics for a dataset. Returns ErrCompute if any error occurs during the computation. When returning an error, the value of Stats struct may be partially written.

func (*Common) StringAsTime

func (s *Common) StringAsTime() string

StringAsTime returns a string representing the statistics expressed in time.Duration.

{min:100ms max:200ms ...}

type ComputeError

type ComputeError struct {
	Errors []string
}

ComputeError is returned when Compute fails to compute a stat.

func (*ComputeError) Error

func (e *ComputeError) Error() string

type StatusDistribution

type StatusDistribution struct {
	Status1xx int
	Status2xx int
	Status3xx int
	Status4xx int
	Status5xx int
}

func ComputeStatusDistribution

func ComputeStatusDistribution(data []int) (StatusDistribution, error)

Jump to

Keyboard shortcuts

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