BivariateMoment(int r, int s, int[] calldata p, int[] calldata q, int[] calldata weights, uint8 precision) returns the weighted mixed moment between the samples x and y.
E[(x−μx)r∗(y−μy)s]
Lenght of p and q and weights must be equal. Precision representes the number of decimal places between 0 and 18. It is applied to r,s,p,q, weights and the output.
function BivariateMoment(int r, int s, int[] calldata p, int[] calldata q, int[] calldata weights, uint8 precision) external returns (int)
Under the hood, the following functions are utilized directly in the Neural client.
func (con *NeuralMath) BivariateMoment(gas *big.Int, r, s *big.Int, p, q, weights []*big.Int, precision uint8) (*big.Int, error, *big.Int) {
mul, err := validatePrecision(precision)
if err != nil {
return nil, err, nil
}
if len(p) != len(q) {
return nil, errors.New("p must have the same length as q"), nil
}
if len(p) != len(weights) {
return nil, errors.New("p must have the same length as weights"), nil
}
rf, err := toFloat(r, mul)
if err != nil {
return nil, err, nil
}
sf, err := toFloat(r, mul)
if err != nil {
return nil, err, nil
}
pf, err := toFloats(p, mul)
if err != nil {
return nil, err, nil
}
qf, err := toFloats(q, mul)
if err != nil {
return nil, err, nil
}
wf, err := toFloats(weights, mul)
if err != nil {
return nil, err, nil
}
moment := stat.BivariateMoment(rf, sf, pf, qf, wf)
return toBig(moment, mul), nil, nil
}