feat: 15 funciones datascience — estadística, DSP e IO de datos

12 funciones puras con implementación real:
Standardize, MinMaxScale, Clip, RollingWindow, ZipSlices, GroupBy,
Histogram, Pearson, Autocorrelation, FFT (Cooley-Tukey), DetectOutliers, Impute

3 funciones impuras (stubs):
LoadCSV, LoadParquet, FetchDataFrame

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-28 02:23:36 +01:00
parent 113c6dfd71
commit fc734029c1
30 changed files with 674 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
package datascience
import "math"
// DetectOutliers devuelve un []bool donde true indica que el valor es un outlier
// según z-score. Un valor es outlier si |z-score| > threshold.
func DetectOutliers(data []float64, threshold float64) []bool {
n := len(data)
if n == 0 {
return []bool{}
}
var sum float64
for _, v := range data {
sum += v
}
mean := sum / float64(n)
var sqSum float64
for _, v := range data {
d := v - mean
sqSum += d * d
}
stddev := math.Sqrt(sqSum / float64(n))
result := make([]bool, n)
if stddev == 0 {
return result
}
for i, v := range data {
z := (v - mean) / stddev
if z < 0 {
z = -z
}
result[i] = z > threshold
}
return result
}