samplestats

package
v0.0.0-...-b433dbc Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByDelta

func ByDelta(rows []Row, i, j int) bool

ByDelta sorts tables by the Delta column.

func ByName

func ByName(rows []Row, i, j int) bool

ByName sorts tables by the trace id name column

func Sort

func Sort(rows []Row, order Order)

Sort sorts a Table t (in place) by the given order.

Types

type Config

type Config struct {
	// Alpha is the p-value cutoff to report a change as significant. If 0 then
	// the default value of 0.05 is used.
	Alpha float64

	// Order is used to sort the results. If none is supplied then results are
	// sorted by Delta.
	Order Order

	// IQRR, if true, causes outliers to be removed via the Interquartile Rule.
	IQRR bool

	// All, if true, returns all rows, even if no significant change was seen
	// for a now. If false then only return rows with significant changes.
	All bool

	// Test is the kind of statistical test to do. Defaults to UTest.
	Test Test
}

Config controls the analysis done on the samples.

type Metrics

type Metrics struct {
	Mean    float64
	StdDev  float64
	Values  []float64 // May have outliers removed.
	Percent float64
}

Metrics are calculated for each test.

type Order

type Order func(rows []Row, i, j int) bool

An Order defines a sort order for a slice of Rows.

func Reverse

func Reverse(order Order) Order

Reverse returns the reverse of the given order.

type Result

type Result struct {
	// Rows, with one Row per result.
	Rows []Row

	// Skipped is the number of results we skipped, because either we couldn't
	// calculate the statistics, or there wasn't data in both 'before' and
	// 'after'.
	Skipped int
}

Result is the resulting calculations returned from Analyze.

func Analyze

func Analyze(config Config, before, after map[string]parser.Samples) Result

Analyze returns an analysis of the samples as a slice of Row.

type Row

type Row struct {
	// Name of sample, i.e. its trace name.
	Name string

	// The full set of Params for the trace.
	Params paramtools.Params

	// Samples are the metrics for both samples, the first is 'before', the
	// second is 'after'. See Analyze().
	Samples [2]Metrics

	// The change in mean between before and after samples, as a percent. I.e.
	// from -100 to 100. This will be NaN if no significant change is found
	// between the samaple.
	Delta float64

	// P is p-value for the specified test for the null hypothesis that the
	// samples are from the same population.
	P float64

	// Note of any issues that arose during calculations.
	Note string
}

Row is a single row in the results.

type Test

type Test string

Test is the kind of statistical test we are doing.

const (
	// UTest is the Mann-Whitney U test.
	UTest Test = "utest"

	// TTest is the Two Sample Welch test.
	TTest Test = "ttest"
)

Jump to

Keyboard shortcuts

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