Commit 145edeb2 authored by Ferdinand Fischer's avatar Ferdinand Fischer
Browse files

fixed bug in misc.binomial

parent 06252883
......@@ -6,10 +6,10 @@ arguments
k (1,1) double {mustBeInteger};
end
if p >= 0
b = gamma(p+1) / gamma(k+1) / gamma(p-k + 1);
else
if p < 0 && k ~= 0
b = (-1)^k * misc.binomial( -p + k -1, k);
else
b = gamma(p+1) / gamma(k+1) / gamma(p-k + 1);
end
end
......
......@@ -19,7 +19,7 @@ end
testCase.verifyEqual( misc.binomial(2.5, 2), 1.875)
testCase.verifyEqual( misc.binomial(-1, 4), (-1)^4)
for k = 1:3
for k = -1:3
% test non integer over zero
testCase.verifyEqual( misc.binomial( k*0.3, 0), 1);
% test non integer over one
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment