NoverK

버전 1.2.1 (3.75 KB) 작성자: Jan
Fast and accurate N over K
다운로드 수: 25
업데이트 날짜: 2022/2/22

라이선스 보기

N over K
A fast and stable computation of: n! / (k! * (n-k)!)
This is the number of combinations, if k elements are chosen out of n without
repetitions and order.
[c, OF] = NoverK(n, k)
INPUT:
n, k: Scalars with real integer values, floating point or integer types.
OUTPUT:
c: Result as same type as the inputs.
OF: Logical flag, true on overflow.
NOTES:
- Alternatives:
prod(((n-k+1):n) ./ (1:k)) 3 times slower, less accurate
nchoosek(n, k) 20 times slower, less accurate:
nchoosek(61, 17) 536830054536826 (14 valid digits only)
NoverK(61, 17) 536830054536825
The accuracy and overflow handling was the main reason to write this function.
Tested: Matlab 2009a (no U/INT64!), 2015b(32/64), 2016b, 2018b, Win10

인용 양식

Jan (2024). NoverK (https://www.mathworks.com/matlabcentral/fileexchange/100174-noverk), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2018b
R2009b 이상 릴리스와 호환
플랫폼 호환성
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
버전 게시됨 릴리스 정보
1.2.1

Catch another overflow.

1.2.0

Bugfix

1.1.0

Faster validity checks, better overflow detection

1.0.0