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

10
LINES

< > BotCompany Repo | #1036435 // averageAndStandardDeviation

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (10031L/55K).

1  
static AverageAndStandardDeviation averageAndStandardDeviation(double... a) {
2  
  new AverageAndStandardDeviation out;
3  
  if (empty(a)) ret out;
4  
  double avg = doubleAverage(a);
5  
  double sum = 0;
6  
  for i over a: sum += sqr(a[i]-avg);
7  
  out.avg = avg;
8  
  out.standardDeviation = sqrt(sum/l(a));
9  
  ret out;
10  
}

Author comment

Began life as a copy of #1010189

download  show line numbers  debug dex  old transpilations   

Travelled to 2 computer(s): mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1036435
Snippet name: averageAndStandardDeviation
Eternal ID of this version: #1036435/3
Text MD5: 3952dc6847b1f8c0b068f235ababc5e5
Transpilation MD5: 361a9f87b9008c30e7a3fbcec7b470ba
Author: stefan
Category: javax / maths
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-12-12 00:42:48
Source code size: 313 bytes / 10 lines
Pitched / IR pitched: No / No
Views / Downloads: 131 / 194
Version history: 2 change(s)
Referenced in: [show references]