Ticket #136 (closed defect: fixed)

Opened 2 years ago

Last modified 2 years ago

Add mean/average and median to Base

Reported by: beau@hartshornesoftware.com Assigned to: beau@hartshornesoftware.com
Priority: low Milestone:
Component: component2 Version: 2.0
Severity: normal Keywords:
Cc:

Description

Here's the start of an implementation:

/* http://www.nist.gov/dads/HTML/mean.html */ 
var mean = function() { 
     var data = flattenArguments(arguments); 
     return sum(data) / data.length; 

}; 

/* http://www.nist.gov/dads/HTML/median.html */ 
var median = function() { 
     var data = flattenArguments(arguments); 
     data.sort(compare); 
     if (data.length % 2 == 0) { 
         var upper = data.length / 2; 
         return (data[upper] + data[upper - 1]) / 2; 
     } else { 
         return data[(data.length - 1) / 2]; 
     } 
}; 

They need to be optimized a bit, and should return NaN when passed no arguments or an empty list. Need to inline sum() to kill the Iter dependency. They should live in Base along with listMin and listMax. While we're at it, listMin and listMax should probably return the same values as Math.min() and Math.max().

http://groups.google.com/group/mochikit/browse_thread/thread/32378e01109df541

Change History

06/22/06 09:13:26 changed by beau@hartshornesoftware.com

  • status changed from new to assigned.

07/21/06 13:42:59 changed by beau@hartshornesoftware.com

  • status changed from assigned to closed.
  • type changed from defect to enhancement.
  • resolution set to fixed.

10/04/06 11:38:18 changed by kkkkoaa01102006aa

  • version set to 2.0.
  • milestone set to milestone1.

Keep a good job up! phentermine mattrass handbag http://hifrien01102006.info

10/05/06 08:45:05 changed by kkkkoaa01102006aa

Keep a good job up! phentermine mattrass handbag http://hifrien01102006.info

10/16/06 08:26:20 changed by karel

  • priority changed from normal to low.
  • type changed from enhancement to defect.
  • component changed from component1 to component2.

ionolsen19 May we exchange links with your site?www_5_2 asdf www_5_3 asdf www_5_4 asdf www_5_5 asdf www_5_6 asdf

11/18/06 15:51:23 changed by

  • milestone deleted.

Milestone milestone1 deleted