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 {returnnil, err, nil }iflen(p) !=len(q) {returnnil, errors.New("p must have the same length as q"), nil }iflen(p) !=len(weights) {returnnil, errors.New("p must have the same length as weights"), nil } rf, err :=toFloat(r, mul)if err !=nil {returnnil, err, nil } sf, err :=toFloat(r, mul)if err !=nil {returnnil, err, nil } pf, err :=toFloats(p, mul)if err !=nil {returnnil, err, nil } qf, err :=toFloats(q, mul)if err !=nil {returnnil, err, nil } wf, err :=toFloats(weights, mul)if err !=nil {returnnil, err, nil } moment := stat.BivariateMoment(rf, sf, pf, qf, wf)returntoBig(moment, mul), nil, nil}