Module: Toybox.Math
Overview
The Math Module provides various math methods available for use by Apps.
Classes Under Namespace
Classes: Filter, FirFilter, IirFilter
Constant Summary
Constant Variables
Type  Name  Value  Since  Description 

Type  E  2.7182818284590452354  API Level 1.0.0 
32bit floating point representation of E 
Type  PI  3.14159265358979323846  API Level 1.0.0 
32bit floating point representation of PI 
Instance Method Summary collapse

acos(x as Numeric) as Decimal
Get the arc cosine of an angle.

asin(x as Numeric) as Decimal
Get the arc sine of an angle.

atan(x as Numeric) as Decimal
Get the arc tangent of an angle.

atan2(y as Numeric, x as Numeric) as Decimal
Get the arc tangent of y/x in radians.

ceil(x as Numeric) as Numeric
Compute the ceiling of a value.

cos(x as Numeric) as Decimal
Get the cosine of an angle.

floor(x as Numeric) as Numeric
Compute the floor of a value.

ln(x as Numeric) as Decimal
Get natural logarithm of a value.

log(x as Numeric, base as Numeric) as Decimal
Get logarithm of a value using the specified base.

mean(data as Array<Numeric>) as Double
Get the arithmetic mean (average) of an array of data.

mode(data as Array<Object>) as Object
Get the most common value found in an array of data.

pow(x as Numeric, y as Numeric) as Decimal
Calculate x to the power of y.

rand() as Number
Returns a pseudorandom Number.

round(x as Numeric) as Numeric
Round a value.

sin(x as Numeric) as Decimal
Get the sine of an angle.

sqrt(x as Numeric) as Decimal
Calculate the square root of a value.

srand(seed as Number)
Seed the random number generator.

stdev(data as Array<Numeric>, xbar as Double or Null) as Double
Get the standard deviation of a sample of population data.

tan(x as Numeric) as Decimal
Get the tangent of an angle.

toDegrees(x as Numeric) as Decimal
Convert an angle from radians to degrees.

toRadians(x as Numeric) as Decimal
Convert an angle from degrees to radians.

variance(data as Array<Numeric>, xbar as Numeric or Null) as Double
Get the sample variance of an array of data.