// StandardScore normalizes every columns with "Standard Score".
StandardScore normalizes every columns with "Standard Score".
// StandardScore normalizes every columns with " Standard Score " .
func StandardScore(data [][]float64) [][]float64 {
	out := make([][]float64, len(data))
	if len(data) == 0 {
		return out
	}
	for k := 0; k < len(out); k++ {
		out[k] = make([]float64, len(data[0]))
	}
	for k := 0; k < len(data[0]); k++ {
		row := make([]float64, 0)
		for i := 0; i < len(out); i++ {
			row = append(row, data[i][k])
		}
		mean, err := stats.Mean(row)
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
		stderv, err := stats.StandardDeviationPopulation(row)
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
		for i := 0; i < len(out); i++ {
			out[i][k] = (data[i][k] - mean) / stderv
		}
	}
	return out
}
func StandardScore ( data [ ] [ ] float64 ) [ ] [ ] float64 { out := make ( [ ] [ ] float64 , len ( data ) ) if len ( data ) == 0 { return out } for k := 0 ; k < len ( out ) ; k ++ { out [ k ] = make ( [ ] float64 , len ( data [ 0 ] ) ) } for k := 0 ; k < len ( data [ 0 ] ) ; k ++ { row := make ( [ ] float64 , 0 ) for i := 0 ; i < len ( out ) ; i ++ { row = append ( row , data [ i ] [ k ] ) } mean , err := stats . Mean ( row ) if err != nil { fmt . Println ( err ) os . Exit ( 1 ) } stderv , err := stats . StandardDeviationPopulation ( row ) if err != nil { fmt . Println ( err ) os . Exit ( 1 ) } for i := 0 ; i < len ( out ) ; i ++ { out [ i ] [ k ] = ( data [ i ] [ k ] - mean ) / stderv } } return out }
StandardScore normalizes every columns with "Standard Score".
StandardScore normalizes every columns with " Standard Score " .