public static function weightedMovingAverage(array $numbers, int $n, array $weights) : array
{
if (count($weights) !== $n) {
throw new Exception\BadDataException('Number of weights must equal number of n-points');
}
$m = count($numbers);
$∑w = array_sum($weights);
$WMA = [];
for ($i = 0; $i <= $m - $n; $i++) {
$∑wp = array_sum(Map\Multi::multiply(array_slice($numbers, $i, $n), $weights));
$WMA[] = $∑wp / $∑w;
}
return $WMA;
}