Module mathlib

Math utility functions.

Copyright © 2007-2014 Zuse Institute Berlin

Version: $Id$

Authors: Marie Hoffmann (ozymandiaz147@googlemail.com).

Description

Math utility functions.

Data Types

vector()

vector() = [number(), ...]

Function Index

median/1Median of an unsorted non-empty list of numbers, i.e.
vecAdd/2Add two vectors X,Y, i.e.
vecSub/2Substract two vectors X,Y, i.e.
vecMult/2Multiply vector V with a scalar S.
vecWeightedAvg/4
euclideanDistance/1Euclidean distance between origin and V.
euclideanDistance/2Euclidean distance between two vectors.
u/1Unit vector u(v) = v/||v||.
nearestCentroid/2Get the nearest centroid to U from the list Centroids, including the euclidian distance.
closestPoints/1Find indices of closest centroids.
zeros_feeder/1
zeros/1Create a list with N zeros.
aggloClustering/2Get closest centroids and merge them if their distance is within Radius.
binomial_coeff/2Calculates the binomial coefficient of n over k for n >= k.
binomial_coeff_feeder/2
factorial_feeder/1
factorial/1calculates N!
gcd/2Calculates the greatest common divisor of two integers.

Function Details

median/1

median(L :: vector()) -> number()

Median of an unsorted non-empty list of numbers, i.e. a vector.

vecAdd/2

vecAdd(X :: vector(), Y :: vector()) -> vector()

Add two vectors X,Y, i.e. X + Y.

vecSub/2

vecSub(X :: vector(), Y :: vector()) -> vector()

Substract two vectors X,Y, i.e. X - Y.

vecMult/2

vecMult(V :: vector(), S :: float()) -> vector()

Multiply vector V with a scalar S.

vecWeightedAvg/4

vecWeightedAvg(V1 :: vector(),
               V2 :: vector(),
               W1 :: float(),
               W2 :: float()) ->
                  vector()

euclideanDistance/1

euclideanDistance(V :: vector()) -> Distance :: float()

Euclidean distance between origin and V.

euclideanDistance/2

euclideanDistance(V :: vector(), W :: vector()) ->
                     Distance :: float()

Euclidean distance between two vectors.

u/1

u(V :: vector()) -> UV :: vector()

Unit vector u(v) = v/||v||

nearestCentroid/2

nearestCentroid(U :: dc_centroids:centroid(),
                T :: dc_centroids:centroids()) ->
                   {Distance :: float(),
                    NearestCentroid :: dc_centroids:centroid()} |
                   none

Get the nearest centroid to U from the list Centroids, including the euclidian distance. The function returns 'none' if no nearest centroid can be found. Ambiguity is resolved by picking the first one of the nearest centroids.

closestPoints/1

closestPoints(Centroids :: dc_centroids:centroids()) ->
                 {dc_centroids:centroid(),
                  dc_centroids:centroid()} |
                 none

Find indices of closest centroids.

zeros_feeder/1

zeros_feeder(N :: 0..10000) -> {0..10000}

zeros/1

zeros(N :: 0) -> []

Create a list with N zeros.

aggloClustering/2

aggloClustering(Centroids :: dc_centroids:centroids(),
                Radius :: number()) ->
                   dc_centroids:centroids()

Get closest centroids and merge them if their distance is within Radius.

binomial_coeff/2

binomial_coeff(N :: non_neg_integer(), K :: non_neg_integer()) ->
                  integer()

Calculates the binomial coefficient of n over k for n >= k. see http://rosettacode.org/wiki/Evaluate_binomial_coefficients#Erlang

binomial_coeff_feeder/2

binomial_coeff_feeder(X :: 0..100, Y :: 0..100) ->
                         {non_neg_integer(), non_neg_integer()}

factorial_feeder/1

factorial_feeder(N :: 0..20) -> {0..20}

factorial/1

factorial(N :: non_neg_integer()) -> pos_integer()

calculates N!

gcd/2

gcd(A :: non_neg_integer(), B :: non_neg_integer()) ->
       non_neg_integer()

Calculates the greatest common divisor of two integers.


Generated by EDoc, Aug 2 2016, 13:43:23.