Skip to content

Commit

Permalink
去掉多餘的斷言
Browse files Browse the repository at this point in the history
  • Loading branch information
TimLai666 committed Sep 14, 2024
1 parent 963d7b5 commit 0306aec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions stats/correlation.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ func pearsonCorrelation(dlX, dlY insyra.IDataList) *big.Rat {
cov := Covariance(dlX, dlY)

// 計算標準差
stdX := new(big.Rat).SetFloat64(dlX.Stdev().(float64))
stdY := new(big.Rat).SetFloat64(dlY.Stdev().(float64))
stdX := new(big.Rat).SetFloat64(dlX.Stdev())
stdY := new(big.Rat).SetFloat64(dlY.Stdev())

// 防止除以0
if stdX.Sign() == 0 || stdY.Sign() == 0 {
Expand Down
8 changes: 4 additions & 4 deletions stats/ttest.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func SingleSampleTTest(data insyra.IDataList, mu float64) *TTestResult {
mean := data.Mean()

// 計算標準差和標準誤差
stddev := data.Stdev().(float64)
stddev := data.Stdev()
standardError := stddev / math.Sqrt(float64(n))

// 計算 t 值
Expand Down Expand Up @@ -60,8 +60,8 @@ func TwoSampleTTest(data1, data2 insyra.IDataList, equalVariance bool) *TTestRes
mean2 := data2.Mean()

// 計算兩個樣本的標準差
stddev1 := data1.Stdev().(float64)
stddev2 := data2.Stdev().(float64)
stddev1 := data1.Stdev()
stddev2 := data2.Stdev()

var standardError float64
var df int
Expand Down Expand Up @@ -110,7 +110,7 @@ func PairedTTest(data1, data2 insyra.IDataList) *TTestResult {

// 計算差值的均值和標準差
meanDiff := insyra.NewDataList(diffs).Mean()
stddevDiff := insyra.NewDataList(diffs).Stdev().(float64)
stddevDiff := insyra.NewDataList(diffs).Stdev()

// 計算 t 值
standardError := stddevDiff / math.Sqrt(float64(n))
Expand Down

0 comments on commit 0306aec

Please sign in to comment.