sum_by_weightxxxxxxxxxxsum_by_weight(weights, elements)xxxxxxxxxxsum = sum_by_weight(weights, elements)Calculates the weighted sum.
weights specifies the weight vector, and elements is an array of the values of all the elements.
The weighted sum is
where
xxxxxxxxxx>>> from OpenHA.assessment.system import sum_by_weight>>> import numpy as np
>>> weight = np.array([0.1, 0.2, 0.3, 0.4])>>> elements = np.random.random((4,))>>> sum_by_weight(weight, elements)
0.31787561946429277
weights —— The weight vector, specified as an array of positive numeric scalar of length n.
And it should satisfy
elements —— Array of values of all the elements, specified as an array of length n.
| Name of the parameters | Is optional? | Source, dialog or input port? |
|---|---|---|
weights | No | Input port |
elements | No | Input port |