StdScore

function StdScore(int x, int mean, int std, uint8 precision) returns the standard score for the given x, mean and standard deviation.

function StdScore(int x, int mean, int std, uint8 precision) external returns (int)

Precision represents the number of decimal places and can be set between 0 and 18. It is applied to x, mean, std and output. Under the hood, the following functions are utilized directly in the Neural client.

func (con *NeuralMath) StdScore(gas *big.Int, x, mean, std *big.Int, precision uint8) (*big.Int, error, *big.Int) {
	mul, err := validatePrecision(precision)
	if err != nil {
		return nil, err, nil
	}
	xf, err := toFloat(x, mul)
	if err != nil {
		return nil, err, nil
	}
	meanf, err := toFloat(mean, mul)
	if err != nil {
		return nil, err, nil
	}
	stdf, err := toFloat(std, mul)
	if err != nil {
		return nil, err, nil
	}
	stdScore := stat.StdScore(xf, meanf, stdf)
	return toBig(stdScore, mul), nil, nil
}

Last updated