So I have both an HP Prime and an Nspire II CAS Calculator and I want to make it so the Nspire can do the same.

Here is the HP Prime Code that works

n-Erlang distribution (see also Gamma and exponential)

Code:

EXPORT erlang(k,l,n)

// n-Erlang distribution k shape parameter, l=λ >=0 rate parameter

// from Gamma d.; if k=1 -> erlang(1,l,n) = exponential(l,n)

// erlang(k,λ) = gamma(k,1/λ)

BEGIN

local f;

f:=piecewise(n<0,0, l<0, 0, ((l^k)*(n^(k-1)*e^(-l*n)))/(k-1)! );

END;

EXPORT erlang2(k, m, n)

*k shape parameter, m=μ=1/λ >=0 scale parameter* if μ=2 -> chi2 with 2k degree of freedom

BEGIN

local f;

f:=piecewise(n<0,0, m<0, 0, (n^(k-1)*e^(-n/m))/((m^k)*(k-1)!));

END;

EXPORT erlang_cdf(k, l, n)

// k shape parameter, l=λ >=0 rate parameter (μ=1/λ)

BEGIN

local f;

f:= 1- sum((1/X!)*(e^(-l*n))*(l*n)^X,X,0,k-1);

END;

And this is what I tried to do for one of them for the Nspire but I am getting an Argument Error

Define erlang(k,l,n)=

Prgm

local f

f:=piecewise(n<0,0, l<0, 0, ((l^k)*(n^(k-1)*e^(-l*n)))/(k-1)! )

EndPrgm

It seems to look correct and is able to have a "Stored Success" but I feel like I'm doing something wrong. I would really like some help here.