Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

11
LINES

< > BotCompany Repo | #1032705 // AdaptiveAverage ["cooling" average/"aging" average] - running average that gets progressively less sensitive

JavaX source code (desktop) [tags: use-pretranspiled] - run with: x30.jar

Download Jar. Libraryless. Click here for Pure Java version (50L/1K).

1  
sclass AdaptiveAverage {
2  
  double divisor = 1, value, coolDownSpeed = .5;
3  
  
4  
  void add(double d) {
5  
    value = blend(value, d, 1/divisor);
6  
    divisor += coolDownSpeed;
7  
  }
8  
9  
  double get() { ret value; }
10  
  double age() { ret divisor; }
11  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1032705
Snippet name: AdaptiveAverage ["cooling" average/"aging" average] - running average that gets progressively less sensitive
Eternal ID of this version: #1032705/8
Text MD5: b4a789e04d4990af55f1cab6c65089d0
Transpilation MD5: 3307b8186999aeffca220663a00ab7da
Author: stefan
Category: javax / maths
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-02 05:38:20
Source code size: 248 bytes / 11 lines
Pitched / IR pitched: No / No
Views / Downloads: 115 / 522
Version history: 7 change(s)
Referenced in: [show references]