# Spatial pooler boosting and duty cycles

**URL:** <https://discourse.numenta.org/t/spatial-pooler-boosting-and-duty-cycles/1571>\
**Category:** Engineering\
**Tags:** spatial-pooling, visualization\
**Created:** [November 7, 2016, 9:59pm UTC](https://discourse.numenta.org/t/spatial-pooler-boosting-and-duty-cycles/1571 "2016-11-07T21:59:36Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![brev](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/brev/32/5548_2.png) [@brev](https://discourse.numenta.org/u/brev)\
**Post date:** [December 22, 2018, 2:07am UTC](https://discourse.numenta.org/t/spatial-pooler-boosting-and-duty-cycles/1571/10 "2018-12-22T02:07:39Z")

</div>

I’m currently building my first Spatial Pooler, and am working on duty cycles now. I haven’t seen the calculation details documented anywhere, so just in case it’s helpful for other newbs in the future:

* * *

In NuPIC, the calculation is a “running moving average”, which allows you to average with only the previous value, and the new value.

> **[Moving average | Modified moving average](https://en.wikipedia.org/wiki/Moving_average#Modified_moving_average)**
>
> A modified moving average (MMA), running moving average (RMA), or smoothed moving average (SMMA) is defined as:

The actual NuPIC calculation itself is here, and is used for all the different kinds of duty cycles:

> <https://github.com/numenta/nupic/blob/master/src/nupic/algorithms/spatial_pooler.py#L1426-L1428>

- As noted previously, these _dutyCycle_ values are float percentages, 0.0 - 1.0.
- Variable _newValue_ is binary.
- Variable _period_ is an integer, usually hardcoded in NuPIC to 1000.
  - [https://github.com/numenta/nupic/blob/master/src/nupic/algorithms/spatial\_pooler.py#L247](https://github.com/numenta/nupic/blob/master/src/nupic/algorithms/spatial_pooler.py#L247)

- If your spatial pooler has computed less than 1000 iterations, use that number for your _period_ instead:
  - [https://github.com/numenta/nupic/blob/master/src/nupic/algorithms/spatial\_pooler.py#L1020-L1021](https://github.com/numenta/nupic/blob/master/src/nupic/algorithms/spatial_pooler.py#L1020-L1021)

---

_[View the full topic](https://discourse.numenta.org/t/spatial-pooler-boosting-and-duty-cycles/1571)._
