Data analysis (six)

Weighted average

Sample: S = [S . 1 , S 2 , ..., S n- ]

Weight: W is = [W . 1 , W 2 , ..., W n- ]

Weighted average: A = (S . 1 W . 1 + S 2 W 2 + ... + S n- W n- ) / (W . 1 + W 2 + ... + W n- )

np.average(closing_prices, weights=volumes)

 

Guess you like

Origin www.cnblogs.com/maplethefox/p/11458496.html