Libraryless. Click here for Pure Java version (9219L/50K).
1 | static double standardDeviation(int... a) { |
2 | if (empty(a)) ret 0; |
3 | double avg = doubleAverage(a), sum = 0; |
4 | for i over a: sum += sqr(a[i]-avg); |
5 | ret sqrt(sum/l(a)); |
6 | } |
7 | |
8 | static double standardDeviation(double... a) { |
9 | if (empty(a)) ret 0; |
10 | double avg = doubleAverage(a), sum = 0; |
11 | for i over a: sum += sqr(a[i]-avg); |
12 | ret sqrt(sum/l(a)); |
13 | } |
14 | |
15 | static double standardDeviation(Collection<Double> a) { |
16 | if (empty(a)) ret 0; |
17 | double avg = doubleAverage(a), sum = 0; |
18 | for (double d : a) sum += sqr(d-avg); |
19 | ret sqrt(sum/l(a)); |
20 | } |
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1010189 |
Snippet name: | standardDeviation |
Eternal ID of this version: | #1010189/6 |
Text MD5: | 231fd4fa17f45a2735662e50f05f87ea |
Transpilation MD5: | c18fb900855169400225fb2848a18ee0 |
Author: | stefan |
Category: | javax / maths |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-06-01 18:18:33 |
Source code size: | 550 bytes / 20 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 472 / 601 |
Version history: | 5 change(s) |
Referenced in: | [show references] |