Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. General Discussion
  3. Rolling average and standard deviation.....

Rolling average and standard deviation.....

Scheduled Pinned Locked Moved General Discussion
3 Posts 2 Posters 63 Views 2 Watching
  • 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.
  • skywatchS Offline
    skywatchS Offline
    skywatch
    wrote on last edited by
    #1

    I have a number of variables on a node that I would like to calculate a running average for and one or two that I would like to calculate standard deviation for.

    With limited memory on a pro mini I wonder if anyone has already done this or has any ideas on the best way to approach it?

    YveauxY 1 Reply Last reply
    0
    • skywatchS skywatch

      I have a number of variables on a node that I would like to calculate a running average for and one or two that I would like to calculate standard deviation for.

      With limited memory on a pro mini I wonder if anyone has already done this or has any ideas on the best way to approach it?

      YveauxY Offline
      YveauxY Offline
      Yveaux
      Mod
      wrote on last edited by Yveaux
      #2

      @skywatch I usually use an exponential moving average (https://en.wikipedia.org/wiki/Moving_average) as it doesn't require keeping a sliding window of the past x values.
      The idea is simple: new values are averaged over previous values with low weight.

      Eg

      avg = (avg*(weight-1) + new) / weight
      

      weight is just a factor (as would the size of your window be). Large weight causes slow response to changes. If working with integer types pick a power of 2 for the weight, so the compiler optimizes the division to a simple bitshift operation instead of a real division.

      http://yveaux.blogspot.nl

      skywatchS 1 Reply Last reply
      4
      • YveauxY Yveaux

        @skywatch I usually use an exponential moving average (https://en.wikipedia.org/wiki/Moving_average) as it doesn't require keeping a sliding window of the past x values.
        The idea is simple: new values are averaged over previous values with low weight.

        Eg

        avg = (avg*(weight-1) + new) / weight
        

        weight is just a factor (as would the size of your window be). Large weight causes slow response to changes. If working with integer types pick a power of 2 for the weight, so the compiler optimizes the division to a simple bitshift operation instead of a real division.

        skywatchS Offline
        skywatchS Offline
        skywatch
        wrote on last edited by
        #3

        @Yveaux Thanks for the pointer, I will take a good look at that. What I need is something light that won't have a growing variable. I thought of using an array as the best option, but I will vertainly look at what you have found. Thank you!

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        29

        Online

        11.7k

        Users

        11.2k

        Topics

        113.1k

        Posts


        Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • MySensors
        • OpenHardware.io
        • Categories
        • Recent
        • Tags
        • Popular