shortcuts/stat/main.go

66 lines
2.6 KiB
Go
Raw Permalink Normal View History

2024-09-28 20:18:36 +00:00
//go:build js && wasm
// +build js,wasm
2024-09-28 16:04:12 +00:00
package main
import (
"fmt"
2024-09-28 20:18:36 +00:00
"l12.xyz/x/shortcuts/stat/src"
2024-09-28 16:04:12 +00:00
2024-09-28 20:18:36 +00:00
"syscall/js"
2024-09-28 16:04:12 +00:00
)
2024-09-28 20:18:36 +00:00
func InitStatExports(this js.Value, args []js.Value) interface{} {
2024-10-01 15:30:09 +00:00
exports := js.Global().Get("Object").New()
2024-09-28 20:18:36 +00:00
exports.Set("Bhattacharyya", js.FuncOf(src.Bhattacharyya))
exports.Set("BivariateMoment", js.FuncOf(src.BivariateMoment))
exports.Set("ChiSquare", js.FuncOf(src.ChiSquare))
exports.Set("CircularMean", js.FuncOf(src.CircularMean))
exports.Set("Correlation", js.FuncOf(src.Correlation))
exports.Set("Covariance", js.FuncOf(src.Covariance))
exports.Set("CrossEntropy", js.FuncOf(src.CrossEntropy))
exports.Set("Entropy", js.FuncOf(src.Entropy))
exports.Set("ExKurtosis", js.FuncOf(src.ExKurtosis))
exports.Set("GeometricMean", js.FuncOf(src.GeometricMean))
exports.Set("HarmonicMean", js.FuncOf(src.HarmonicMean))
exports.Set("Hellinger", js.FuncOf(src.Hellinger))
exports.Set("Histogram", js.FuncOf(src.Histogram))
exports.Set("JensenShannon", js.FuncOf(src.JensenShannon))
exports.Set("Kendall", js.FuncOf(src.Kendall))
exports.Set("KolmogorovSmirnov", js.FuncOf(src.KolmogorovSmirnov))
exports.Set("KullbackLeibler", js.FuncOf(src.KullbackLeibler))
exports.Set("LinearRegression", js.FuncOf(src.LinearRegression))
exports.Set("Mean", js.FuncOf(src.Mean))
exports.Set("MeanStdDev", js.FuncOf(src.MeanStdDev))
exports.Set("MeanVariance", js.FuncOf(src.MeanVariance))
exports.Set("Mode", js.FuncOf(src.Mode))
exports.Set("Moment", js.FuncOf(src.Moment))
exports.Set("MomentAbout", js.FuncOf(src.MomentAbout))
exports.Set("PopMeanStdDev", js.FuncOf(src.PopMeanStdDev))
exports.Set("PopMeanVariance", js.FuncOf(src.PopMeanVariance))
exports.Set("PopStdDev", js.FuncOf(src.PopStdDev))
exports.Set("PopVariance", js.FuncOf(src.PopVariance))
exports.Set("Quantile", js.FuncOf(src.Quantile))
exports.Set("RNoughtSquared", js.FuncOf(src.RNoughtSquared))
exports.Set("ROC", js.FuncOf(src.ROC))
exports.Set("RSquared", js.FuncOf(src.RSquared))
exports.Set("RSquaredFrom", js.FuncOf(src.RSquaredFrom))
exports.Set("Skew", js.FuncOf(src.Skew))
exports.Set("SortWeighted", js.FuncOf(src.SortWeighted))
exports.Set("SortWeightedLabeled", js.FuncOf(src.SortWeightedLabeled))
exports.Set("StdDev", js.FuncOf(src.StdDev))
exports.Set("StdErr", js.FuncOf(src.StdErr))
exports.Set("StdScore", js.FuncOf(src.StdScore))
exports.Set("TOC", js.FuncOf(src.TOC))
exports.Set("Variance", js.FuncOf(src.Variance))
2024-10-01 15:30:09 +00:00
return exports
2024-09-28 16:04:12 +00:00
}
func main() {
2024-09-28 20:18:36 +00:00
wait := make(chan struct{}, 0)
js.Global().Set("__InitStatExports", js.FuncOf(InitStatExports))
2024-09-28 16:04:12 +00:00
fmt.Println("Stats initialized")
2024-09-28 20:18:36 +00:00
<-wait
2024-09-28 16:04:12 +00:00
}