1 Star 4 Fork 12

王布衣/pandas

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
median.go 403 Bytes
一键复制 编辑 原始数据 按行查看 历史
package stat
// Median returns median value of series.
// Linear interpolation is used for odd length.
// TODO:未加验证, 未加速
func Median[T StatType](values []T) DType {
if len(values) == 0 {
return DTypeNaN
}
if len(values) == 1 {
return DType(0)
}
if len(values)%2 == 0 {
i := len(values) / 2
return DType(values[i-1]+values[i]) / 2
}
return DType(values[len(values)/2])
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/quant1x/pandas.git
git@gitee.com:quant1x/pandas.git
quant1x
pandas
pandas
v0.6.4

搜索帮助