Transpiled version (9988L) is out of date.
sclass Average { gettable double sum; gettable double n; void add aka addSample(double d) { ++n; sum += d; } void add(double d, double weight) { n += weight; sum += d*weight; } void remove(double d) { add(d, -1); } double get aka avg aka average aka getAverage() { ret doubleRatio(sum, n); } bool isEmpty() { ret n == 0; } toString { ret get() + " (n=" + n + ")"; } void clear { n = 0; sum = 0; } double size aka count() { ret n; } }
Began life as a copy of #1019129
download show line numbers debug dex old transpilations
Travelled to 8 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1029191 |
Snippet name: | Average |
Eternal ID of this version: | #1029191/17 |
Text MD5: | 9d741490546e1c9ca0a9c80d4d732791 |
Author: | stefan |
Category: | javax / maths |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-12-16 14:01:09 |
Source code size: | 551 bytes / 33 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 312 / 769 |
Version history: | 16 change(s) |
Referenced in: | [show references] |