Documentation
¶
Index ¶
- func CalculateMoment(dl insyra.IDataList, n int, central bool) *big.Rat
- func Correlation(dlX, dlY insyra.IDataList, method CorrelationMethod, highPrecision ...bool) interface{}
- func Covariance(dlX, dlY insyra.IDataList) *big.Rat
- func Kurtosis(data interface{}, method ...int) interface{}
- func Skewness(sample interface{}, method ...int) interface{}
- type ChiSquareTestResult
- type CorrelationMethod
- type FTestResult
- type LinearRegressionResult
- type OneWayANOVAResult
- type PCAResult
- type RepeatedMeasuresANOVAResult
- type TTestResult
- type TwoWayANOVAResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalculateMoment ¶ added in v0.0.3
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
Covariance calculates the covariance between two datasets. Always returns *big.Rat.
Types ¶
type ChiSquareTestResult ¶ added in v0.0.6
func ChiSquareTest ¶ added in v0.0.6
func ChiSquareTest(input interface{}, p []float64, rescaleP bool) *ChiSquareTestResult
ChiSquareTest supports both DataList (1D) and DataTable (2D) for chi-square tests.
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 FTestResult ¶ added in v0.0.6
func FTestForVarianceEquality ¶ added in v0.0.6
func FTestForVarianceEquality(data1, data2 *insyra.DataList) *FTestResult
FTestForVarianceEquality performs an F-test for variance equality
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 OneWayANOVAResult ¶ added in v0.0.7
type OneWayANOVAResult struct {
SSB float64 // Between-group Sum of Squares
SSW float64 // Within-group Sum of Squares
FValue float64 // F-value
PValue float64 // P-value
DFB int // Between-group Degrees of Freedom
DFW int // Within-group Degrees of Freedom
TotalSS float64 // Total Sum of Squares
}
func OneWayANOVA_WideFormat ¶ added in v0.0.7
func OneWayANOVA_WideFormat(dataTable insyra.IDataTable) *OneWayANOVAResult
type PCAResult ¶ added in v0.0.8
type PCAResult struct {
Components insyra.IDataTable // 主成分存為 DataTable
Eigenvalues []float64 // 對應的特徵值
ExplainedVariance []float64 // 每個主成分解釋的變異百分比
}
PCAResult contains the results of a Principal Component Analysis.
func PCA ¶ added in v0.0.8
func PCA(dataTable insyra.IDataTable, nComponents ...int) *PCAResult
PCA calculates the Principal Component Analysis of a DataTable. The function returns a PCAResult struct containing the principal components, eigenvalues, and explained variance. The number of components to extract can be specified using the nComponents parameter. If nComponents is not specified or exceeds the number of columns, all components will be extracted.
type RepeatedMeasuresANOVAResult ¶ added in v0.0.8
type RepeatedMeasuresANOVAResult struct {
SSB float64 // Between-group Sum of Squares
SSW float64 // Within-group Sum of Squares
FValue float64 // F-value
PValue float64 // P-value
DFB int // Between-group Degrees of Freedom
DFW int // Within-group Degrees of Freedom
DFSubj int // Degrees of Freedom for subjects
TotalSS float64 // Total Sum of Squares
}
func RepeatedMeasuresANOVA_WideFormat ¶ added in v0.0.8
func RepeatedMeasuresANOVA_WideFormat(dataTable insyra.IDataTable) *RepeatedMeasuresANOVAResult
RepeatedMeasuresANOVA_WideFormat calculates the repeated measures ANOVA of the given data table. Use wide data format to calculate the ANOVA. It returns a pointer to a RepeatedMeasuresANOVAResult struct containing the results.
type TTestResult ¶ added in v0.0.4
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.
type TwoWayANOVAResult ¶ added in v0.0.7
type TwoWayANOVAResult struct {
SSA float64 // Factor A Sum of Squares
SSB float64 // Factor B Sum of Squares
SSAB float64 // Interaction Sum of Squares
SSW float64 // Within-group Sum of Squares
FAValue float64 // F-value for Factor A
FBValue float64 // F-value for Factor B
FABValue float64 // F-value for interaction
PAValue float64 // P-value for Factor A
PBValue float64 // P-value for Factor B
PABValue float64 // P-value for interaction
DFA int // Degrees of Freedom for Factor A
DFB int // Degrees of Freedom for Factor B
DFAxB int // Degrees of Freedom for interaction
DFW int // Degrees of Freedom within groups
TotalSS float64 // Total Sum of Squares
}
func TwoWayANOVA_WideFormat ¶ added in v0.0.7
func TwoWayANOVA_WideFormat(dataTable insyra.IDataTable) *TwoWayANOVAResult
TwoWayANOVA calculates the two-way ANOVA of the given data table. Use wide data format to calculate the ANOVA. It returns a pointer to a TwoWayANOVAResult struct containing the results.