func Sem(ix *etable.IdxView, colNm string) []float64 {
	colIdx := ix.Table.ColIdx(colNm)
	if colIdx == -1 {
		return nil
	}
	return SemIdx(ix, colIdx)
}
Sem returns the sample standard error of the mean of non-Null, non-NaN elements in given
IdxView indexed view of an etable.Table, for given column name.
Sample sem is normalized by 1/(n-1) -- see SemPop version for 1/n normalization.
If name not found, nil is returned -- use Try version for error message.
Return value is size of each column cell -- 1 for scalar 1D columns
and N for higher-dimensional columns.
package agg
import (
	"math"
	"github.com/emer/etable/etable"
)
type IdxViewAggFuncIdx func(ix *etable.IdxView, colIdx int) []float64
type IdxViewAggFunc func(ix *etable.IdxView, colIdx int) []float64
type IdxViewAggFuncTry func(ix *etable.IdxView, colIdx int) ([]float64, error)
func CountIdx(ix *etable.IdxView, colIdx int) []float64 {
	return ix.AggCol(colIdx, 0, CountFunc)
}
func Count(ix *etable.IdxView, colNm string) []float64 {
	colIdx := ix.Table.ColIdx(colNm)
	if colIdx == -1 {
		return nil
	}
	return CountIdx(ix, colIdx)
}
func CountTry(ix *etable.IdxView, colNm string) ([]float64, error) {
	colIdx, err := ix.Table.ColIdxTry(colNm)
	if err != nil {
		return nil, err
	}
	return CountIdx(ix, colIdx), nil
}
func SumIdx(ix *etable.IdxView, colIdx int) []float64 {
	return ix.AggCol(colIdx, 0, SumFunc)
}
func Sum(ix *etable.IdxView, colNm string) []float64 {
	colIdx := ix.Table.ColIdx(colNm)
	if colIdx == -1 {
		return nil
	}
	return SumIdx(ix, colIdx)
}
func SumTry(ix *etable.IdxView, colNm string) ([]float64, error) {
	colIdx, err := ix.Table.ColIdxTry(colNm)
	if err != nil {
		return nil, err
	}
	return SumIdx(ix, colIdx), nil
}
func ProdIdx(ix *etable.IdxView, colIdx int) []float64 {
	return ix.AggCol(colIdx, 1, ProdFunc)
}
func Prod(ix *etable.IdxView, colNm string) []float64 {
	colIdx := ix.Table.ColIdx(colNm)
	if colIdx == -1 {
		return nil
	}
	return ProdIdx(ix, colIdx)
}
func ProdTry(ix *etable.IdxView, colNm string) ([]float64, error) {
	colIdx, err := ix.Table.ColIdxTry(colNm)
	if err != nil {
		return nil, err
	}
	return ProdIdx(ix, colIdx), nil
}
func MaxIdx(ix *etable.IdxView, colIdx int) []float64 {
	return ix.AggCol(colIdx, -math.MaxFloat64, MaxFunc)
}
func Max(ix *etable.IdxView, colNm string) []float64 {
	colIdx := ix.Table.ColIdx(colNm)
	if colIdx == -1 {
		return nil
	}
	return MaxIdx(ix, colIdx)
}
func MaxTry(ix *etable.IdxView, colNm string) ([]float64, error) {
	colIdx, err := ix.Table.ColIdxTry(colNm)
	if err != nil {
		return nil, err
	}
	return MaxIdx(ix, colIdx), nil
}
func MinIdx(ix *etable.IdxView, colIdx int) []float64 {
	return ix.AggCol(colIdx, math.MaxFloat64, MinFunc)
}
func Min(ix *etable.IdxView, colNm string) []float64 {
	colIdx := ix.Table.ColIdx(colNm)
	if colIdx == -1 {
		return nil
	}
	return MinIdx(ix, colIdx)
}
func MinTry(ix *etable.IdxView, colNm string) ([]float64, error) {
	colIdx, err := ix.Table.ColIdxTry(colNm)
	if err != nil {
		return nil, err
	}
	return MinIdx(ix, colIdx), nil
}
func MeanIdx(ix *etable.IdxView, colIdx int) []float64 {
	cnt := CountIdx(ix, colIdx)
	if cnt == nil {
		return nil
	}
	mean := SumIdx(ix, colIdx)
	for i := range mean {
		if cnt[i] > 0 {
			mean[i] /= cnt[i]
		}
	}
	return mean
}
func Mean(ix *etable.IdxView, colNm string) []float64 {
	colIdx := ix.Table.ColIdx(colNm)
	if colIdx == -1 {
		return nil
	}
	return MeanIdx(ix, colIdx)
}
func MeanTry(ix *etable.IdxView, colNm string) ([]float64, error) {
	colIdx, err := ix.Table.ColIdxTry(colNm)
	if err != nil {
		return nil, err
	}
	return MeanIdx(ix, colIdx), nil
}
func VarIdx(ix *etable.IdxView, colIdx int) []float64 {
	cnt := CountIdx(ix, colIdx)
	if cnt == nil {
		return nil
	}
	mean := SumIdx(ix, colIdx)
	for i := range mean {
		if cnt[i] > 0 {
			mean[i] /= cnt[i]
		}
	}
	col := ix.Table.Cols[colIdx]
	_, csz := col.RowCellSize()
	vr := ix.AggCol(colIdx, 0, func(idx int, val float64, agg float64) float64 {
		cidx := idx % csz
		dv := val - mean[cidx]
		return agg + dv*dv
	})
	for i := range vr {
		if cnt[i] > 1 {
			vr[i] /= (cnt[i] - 1)
		}
	}
	return vr
}
func Var(ix *etable.IdxView, colNm string) []float64 {
	colIdx := ix.Table.ColIdx(colNm)
	if colIdx == -1 {
		return nil
	}
	return VarIdx(ix, colIdx)
}
func VarTry(ix *etable.IdxView, colNm string) ([]float64, error) {
	colIdx, err := ix.Table.ColIdxTry(colNm)
	if err != nil {
		return nil, err
	}
	return VarIdx(ix, colIdx), nil
}
func StdIdx(ix *etable.IdxView, colIdx int) []float64 {
	std := VarIdx(ix, colIdx)
	for i := range std {
		std[i] = math.Sqrt(std[i])
	}
	return std
}
func Std(ix *etable.IdxView, colNm string) []float64 {
	colIdx := ix.Table.ColIdx(colNm)
	if colIdx == -1 {
		return nil
	}
	return StdIdx(ix, colIdx)
}
func StdTry(ix *etable.IdxView, colNm string) ([]float64, error) {
	colIdx, err := ix.Table.ColIdxTry(colNm)
	if err != nil {
		return nil, err
	}
	return StdIdx(ix, colIdx), nil
}
func SemIdx(ix *etable.IdxView, colIdx int) []float64 {
	cnt := CountIdx(ix, colIdx)
	if cnt == nil {
		return nil
	}
	sem := StdIdx(ix, colIdx)
	for i := range sem {
		if cnt[i] > 0 {
			sem[i] /= math.Sqrt(cnt[i])
		}
	}
	return sem
}