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).

static AverageAndStandardDeviation averageAndStandardDeviation(double... a) {
  new AverageAndStandardDeviation out;
  if (empty(a)) ret out;
  double avg = doubleAverage(a);
  double sum = 0;
  for i over a: sum += sqr(a[i]-avg);
  out.avg = avg;
  out.standardDeviation = sqrt(sum/l(a));
  ret out;
}

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: 130 / 192
Version history: 2 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)