Module emath

Mathematical functions.

Copyright © 2009 Mr Buzz, Inc.

Authors: Jacob Perkins.

Description

Mathematical functions.

Function Index

elfhash/1Calculates ELFHash of character list.
mean/1Calculates mean of list of numbers.
moving_avg/3Calculates moving average given a Ratio.
random/1Drop in replacement for random:uniform.
scale/1Ensures N is between 0 and 1.
scale/3Ensures N is between Min and Max.

Function Details

elfhash/1

elfhash(List::list() | binary()) -> integer()

Calculates ELFHash of character list. See Hash Functions.

mean/1

mean(Nums::[N::number()]) -> number()

Calculates mean of list of numbers. The mean of empty list is 0.

See also: lists:sum/1.

moving_avg/3

moving_avg(Old::number(), New::number(), Ratio::float()) -> number()

Calculates moving average given a Ratio. The new average is (Old * Ratio) + (New * (1 - Ratio)).

random/1

random(N::integer()) -> integer()

Drop in replacement for random:uniform. Provides 'extra randomness' by seeding random with a timestamp before calling random:uniform.

See also: random.

scale/1

scale(N::float()) -> float()

Equivalent to scale(N, 0.0, 1.0).

Ensures N is between 0 and 1.

scale/3

scale(N::number(), Min::number(), Max::number()) -> number()

Ensures N is between Min and Max.

See also: lists:max/1, lists:min/1.


Generated by EDoc, Jul 14 2009, 14:06:01.