• Recent
    • Tags
    • Popular
    • Register
    • Login

    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 support@radixiot.com.

    Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website Mango 5 Documentation Website

    Calculate Standard Deviation, Normal Distribution?

    User help
    2
    4
    3.7k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • R
      rcopeland
      last edited by

      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.

      Thanks!

      1 Reply Last reply Reply Quote 0
      • M
        mlohbihler
        last edited by

        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.

        Best regards,
        Matthew

        1 Reply Last reply Reply Quote 0
        • R
          rcopeland
          last edited by

          Great, thanks!

          1 Reply Last reply Reply Quote 0
          • First post
            Last post