stats

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2024 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateMoment added in v0.0.3

func CalculateMoment(dl insyra.IDataList, n int, central bool) *big.Rat

CalculateMoment calculates the n-th moment of the DataList. Returns the n-th moment. Returns nil if the DataList is empty or the n-th moment cannot be calculated.

func Correlation added in v0.0.4

func Correlation(dlX, dlY insyra.IDataList, method CorrelationMethod, highPrecision ...bool) interface{}

Correlation calculates the correlation coefficient between two datasets. Supports Pearson, Kendall, and Spearman methods. If highPrecision is set to true, it returns *big.Rat, otherwise float64.

func Covariance added in v0.0.4

func Covariance(dlX, dlY insyra.IDataList) *big.Rat

Covariance calculates the covariance between two datasets. Always returns *big.Rat.

func Kurtosis

func Kurtosis(data interface{}, method ...int) interface{}

Kurtosis calculates the kurtosis(sample) of the DataList. Returns the kurtosis. Returns nil if the DataList is empty or the kurtosis cannot be calculated.

func Skewness added in v0.0.3

func Skewness(sample interface{}, method ...int) interface{}

Skewness calculates the skewness(sample) of the DataList. Returns the skewness. Returns nil if the DataList is empty or the skewness cannot be calculated.

Types

type CorrelationMethod added in v0.0.4

type CorrelationMethod int

CorrelationMethod 定義了相關係數的計算方法

const (
	// PearsonCorrelation 表示皮爾森相關係數的計算方法,用於測量線性相關性
	// PearsonCorrelation means Pearson correlation coefficient, used to measure linear correlation.
	PearsonCorrelation CorrelationMethod = iota
	// KendallCorrelation 表示肯德爾秩相關係數的計算方法,用於測量單調相關性
	// KendallCorrelation means Kendall rank correlation coefficient, used to measure monotonic correlation.
	KendallCorrelation
	// SpearmanCorrelation 表示斯皮爾曼秩相關係數的計算方法,基於排序後的數據。
	// SpearmanCorrelation means Spearman rank correlation coefficient, based on sorted data.
	SpearmanCorrelation
)

type LinearRegressionResult added in v0.0.4

type LinearRegressionResult struct {
	Slope            float64   // 斜率
	Intercept        float64   // 截距
	Residuals        []float64 // 殘差
	Rsquared         float64   // R-squared
	AdjustedRsquared float64   // 調整後的 R-squared
	StandardError    float64   // 標準誤差
	TValue           float64   // t 值
	Pvalue           float64   // p 值
}

LinearRegressionResult holds the result of a linear regression, including slope, intercept, and other statistical details.

func LinearRegression added in v0.0.4

func LinearRegression(dlX, dlY insyra.IDataList) *LinearRegressionResult

LinearRegression performs simple linear regression on two datasets (X and Y). It returns the slope, intercept, residuals, R-squared, and other statistical details.

type TTestResult added in v0.0.4

type TTestResult struct {
	TValue float64 // t 值
	PValue float64 // p 值
	Df     int     // 自由度
}

TTestResult holds the result of a t-test, including t-value and p-value.

func PairedTTest added in v0.0.4

func PairedTTest(data1, data2 insyra.IDataList) *TTestResult

PairedTTest performs a paired t-test, comparing the differences between two paired samples. It returns the t-value, p-value, and degrees of freedom.

func SingleSampleTTest added in v0.0.4

func SingleSampleTTest(data insyra.IDataList, mu float64) *TTestResult

SingleSampleTTest performs a single-sample t-test, comparing the mean of the sample to a given value. It returns the t-value, p-value, and degrees of freedom.

func TwoSampleTTest added in v0.0.4

func TwoSampleTTest(data1, data2 insyra.IDataList, equalVariance bool) *TTestResult

TwoSampleTTest performs an independent two-sample t-test, comparing the means of two samples. It returns the t-value, p-value, and degrees of freedom.

Jump to

Keyboard shortcuts

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