Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to

Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website

Calculate Standard Deviation, Normal Distribution?

  • Hello,

    I was wondering if anyone has come up with functions to calculate standard deviation, and come up with a normal distribution graph from any given data set. I understand how it would be possible to calculate standard deviation with meta variables, but it seems like a lot of work to do for something that someone may have done in the past.


  • I added such a function to the WEB-INF/scripts/scriptFunction.js file. The code is:

    function meanAndStdDev(values) {
        if (values == null || values.length == 0)
            return null;
        var mean = 0;
        for (var i = 0; i < values.length; i++)
            mean += values*;
        mean /= values.length;
        var dev = 0;
        var diff;
        for (var i = 0; i < values.length; i++) {
            diff = mean - values*;
            dev += diff * diff;
        dev /= values.length;
        dev = Math.sqrt(dev);
        return { mean: mean, stdDev: dev };

    It has been only lightly tested, but it was ported pretty much verbatim from Java so it should be good. You can add this to the file yourself if you need it before the next release.

  • Great, thanks!