Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I use Holt-Winters Seasonal Dampened Method to compute a two-month sales projection in PHP?
    primarykey
    data
    text
    <p>Holt-Winters is introduced here:</p> <p><a href="http://en.wikipedia.org/wiki/Holt-Winters" rel="nofollow">http://en.wikipedia.org/wiki/Holt-Winters</a></p> <p>The Seasonal Dampened version of it is discussed here (scroll down the page):</p> <p><a href="http://otexts.com/fpp/7/5/" rel="nofollow">http://otexts.com/fpp/7/5/</a></p> <p>In a nutshell, it basically looks at 3 things:</p> <ul> <li>long-term trend</li> <li>short-term trend</li> <li>seasonal trend</li> </ul> <p>It also doesn't average those together, because really what you need is weighted averaging, where seasonal and short-term are more significant than long-term trend, naturally, with financial data trends.</p> <p><em>Given $anYear1 and $anYear2, how do I apply the Holt-Winters Seasonal Dampened Method to forecast 2 more months past the end of $anYear2?</em> Assume $anYear1 is an array of 12 numbers. Assume $anYear2 is an array of a range of 0 to 12 numbers.</p> <p>So, I can fill it with random data like so:</p> <pre><code>&lt;?php $anYear1 = array(); $anYear2 = array(); $nStop = 10; // so we need 11 and 12 of the year for ($i = 1; $i &lt;= 12; $i++) { $anYear1[$i] = rand(200,500); if ($i &lt;= $nStop) { // give it a natural lift like real financial data $anYear2[$i] = rand(400,700); } } $nSeasonRange = 4; // 4 months in a business quarter Therefore, I want to create a function like so: function forecastHoltWinters($anYear1, $anYear2, $nSeasonRange = 4) { /////////////////// // DO MAGIC HERE // /////////////////// // an array with 2 numbers, indicating 2 months forward from end of $anYear2 return $anForecast; } $anForecast = forecastHoltWinters($anYear1, $anYear2, $nSeasonRange); echo "YEAR 1\n"; print_r($anYear1); echo "\n\nYEAR 2\n" print_r($anYear2); echo "\n\nTWO MONTHS FORECAST\n"; print_r($anForecast); </code></pre> <p>Note: I have found a Github example <a href="https://github.com/ianbarber/PHPIR/blob/master/holtwinters.php" rel="nofollow">here</a>, but it doesn't show how to do a projection. It is also discussed <a href="http://phpir.com/smoothing-with-holt-winter" rel="nofollow">here</a>.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload