PaddiM8 / kalker

Scientific calculator with math syntax that supports user-defined variables and functions, complex numbers, and estimation of derivatives and integrals
https://kalker.xyz
MIT License
1.59k stars 70 forks source link

Support for Permutations and Combinations calculation #52

Closed hanani8 closed 2 years ago

hanani8 commented 3 years ago

Forgive me if I am missing it, but it seems like we do not have support permutations and combinations calculation, correct? Can someone confirm this?

I realized this as I was using kalker in my school test. :)

PaddiM8 commented 3 years ago

That's correct, but that's something that should probably be supported! Hm, how would you expect this to work with something like kalker? Simple function? Special syntax? Both? I don't have much experience with these.

I realized this as I was using kalker in my school test.

Wow haha, nice!

hanani8 commented 3 years ago

I think a simple function is a way to go... Ex: perm(n, r) equivalent to nPr comb(n, r) equivalent to nCr

csicar commented 2 years ago

Simple implementation:

nCr(n, k) = n! / (k! * (n-k)!)
nPr(n, k) = n! / (n - k)!

binompdf(k, n, p) = nCr(n, k) * p^k * (1-p)^(n-k)
binomcdf(k, N, p) = sum(0, k, binompdf(n, N, p))