Kapacitor Tickscript example

I have a question about the example provided on github.
I do not understand why we are calculating first the mean and then standard deviation of the computed mean, since sigma itself computes a running mean would this not flat out the data?
There may be a need for this but i want to know if there are other ways and logic applied to use sigma/stddev for alerting.
Goal is to have as little false positives as possible but with this it may miss the hits?

[Example mem_alert_stream.tick]