Packageflare.util
Classpublic class Stats

Utility class for computing statistics for a collection of values.



Public Properties
 PropertyDefined by
  average : Number
[read-only] The average of all the values (for numerical data).
Stats
  count : Number
[read-only] The total number of values.
Stats
  dataType : int
[read-only] The data type of the collection, one of NUMBER, DATE, or OBJECT.
Stats
  distinct : Number
[read-only] The total number of distinct values.
Stats
  distinctValues : Array
[read-only] A sorted array of all unique values in the collection.
Stats
  maxDate : Date
[read-only] The maximum value (for date/time values).
Stats
  maximum : Number
[read-only] The maximum value (for numerical data).
Stats
  maxObject : Object
[read-only] The maximum value (for arbitrary objects).
Stats
  minDate : Date
[read-only] The minimum value (for date/time values).
Stats
  minimum : Number
[read-only] The minimum value (for numerical data).
Stats
  minObject : Object
[read-only] The minimum value (for arbitrary objects).
Stats
  stddev : Number
[read-only] The standard deviation of all the values (for numerical data).
Stats
  stderr : Number
[read-only] The standard error of all the values (for numerical data).
Stats
  sum : Number
[read-only] The sum of all the values (for numerical data).
Stats
  values : Array
[read-only] A sorted array of all the values.
Stats
Public Methods
 MethodDefined by
  
Stats(data:Array, field:String = null, comparator:Function = null, copy:Boolean = true)
Creates a new Stats instance using the given input data.
Stats
  
equal(a:*, b:*):Boolean
[static] Tests for equality between two values.
Stats
Public Constants
 ConstantDefined by
  DATE : int = 1
[static] Constant indicating date/time values.
Stats
  NUMBER : int = 0
[static] Constant indicating numerical values.
Stats
  OBJECT : int = 2
[static] Constant indicating arbitrary object values.
Stats
Property detail
averageproperty
average:Number  [read-only]

The average of all the values (for numerical data).

Implementation
    public function get average():Number
countproperty 
count:Number  [read-only]

The total number of values.

Implementation
    public function get count():Number
dataTypeproperty 
dataType:int  [read-only]

The data type of the collection, one of NUMBER, DATE, or OBJECT.

Implementation
    public function get dataType():int
distinctproperty 
distinct:Number  [read-only]

The total number of distinct values.

Implementation
    public function get distinct():Number
distinctValuesproperty 
distinctValues:Array  [read-only]

A sorted array of all unique values in the collection.

Implementation
    public function get distinctValues():Array
maxDateproperty 
maxDate:Date  [read-only]

The maximum value (for date/time values).

Implementation
    public function get maxDate():Date
maximumproperty 
maximum:Number  [read-only]

The maximum value (for numerical data).

Implementation
    public function get maximum():Number
maxObjectproperty 
maxObject:Object  [read-only]

The maximum value (for arbitrary objects).

Implementation
    public function get maxObject():Object
minDateproperty 
minDate:Date  [read-only]

The minimum value (for date/time values).

Implementation
    public function get minDate():Date
minimumproperty 
minimum:Number  [read-only]

The minimum value (for numerical data).

Implementation
    public function get minimum():Number
minObjectproperty 
minObject:Object  [read-only]

The minimum value (for arbitrary objects).

Implementation
    public function get minObject():Object
stddevproperty 
stddev:Number  [read-only]

The standard deviation of all the values (for numerical data).

Implementation
    public function get stddev():Number
stderrproperty 
stderr:Number  [read-only]

The standard error of all the values (for numerical data).

Implementation
    public function get stderr():Number
sumproperty 
sum:Number  [read-only]

The sum of all the values (for numerical data).

Implementation
    public function get sum():Number
valuesproperty 
values:Array  [read-only]

A sorted array of all the values.

Implementation
    public function get values():Array
Constructor detail
Stats()constructor
public function Stats(data:Array, field:String = null, comparator:Function = null, copy:Boolean = true)

Creates a new Stats instance using the given input data. If the field argument is null, it is assumed that the input data array directly contains the values to analyze. If the field argument is non-null, values will be extracted from the objects in the input array using the specified property name.

Parameters
data:Array — an input data array. The data to analyze may be contained directly in the array, or may be properties of the objects contained in the array.
 
field:String (default = null) — a property name. This property will be used to extract data values from the objects in the data array. If null, the objects in the data array will be used directly.
 
comparator:Function (default = null) — the comparator function to use to sort the data. If null, the natural sort order will be used.
 
copy:Boolean (default = true) — flag indicating if the input data array should be copied to a new array. This flag only applied when the field argument is null. In false, the input data array will be sorted. If true, the array will be copied before being sorted. The default behavior is to make a copy.
Method detail
equal()method
public static function equal(a:*, b:*):Boolean

Tests for equality between two values. This method is necessary because the == operator checks object equality and not value equality for Date instances.

Parameters
a:* — the first object to compare
 
b:* — the second object to compare

Returns
Boolean
Constant detail
DATEconstant
public static const DATE:int = 1

Constant indicating date/time values.

NUMBERconstant 
public static const NUMBER:int = 0

Constant indicating numerical values.

OBJECTconstant 
public static const OBJECT:int = 2

Constant indicating arbitrary object values.