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.
The actual NuPIC calculation itself is here, and is used for all the different kinds of duty cycles:
- 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.
- If your spatial pooler has computed less than 1000 iterations, use that number for your period instead: