Skip to content

Instantly share code, notes, and snippets.

@jlouis
Created July 14, 2014 08:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jlouis/3e795372914fdd75bfd4 to your computer and use it in GitHub Desktop.
Save jlouis/3e795372914fdd75bfd4 to your computer and use it in GitHub Desktop.
-module(agner).
-export([ec/2]).
fac(N) ->
lists:foldl(fun erlang:'*'/2, 1, lists:seq(1, N)).
ec(M, U) ->
X = math:pow(U, M) / fac(M),
Rho = U / M,
S = lists:sum([math:pow(U, K) / fac(K) || K <- lists:seq(0, M-1)]),
X / (X + (1 - Rho) * S).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment