GithubHelp home page GithubHelp logo

Comments (5)

axkr avatar axkr commented on May 23, 2024

Version 3.4.1 in IDE mode you can input the functions like this

    Binomial(17,13)

    Factorial(0.75)

Can you give some examples of your calculations which go wrong.

from ncalc.

lwchkg avatar lwchkg commented on May 23, 2024

Please refer to the screenshot below. I've seen all the ceiling operators, and that's the mistake.

The correct way to calculate Comb(n, r) is n!/(r!(n-r)!), non-negative integers or not. There should not be any rounding up or rounding down. So don't round off the inputs.

Similarly, we have Perm(n, r) = n!/r! for all numbers.

If you wonder what is n! for non-integer n, then take n! = Gamma(n+1). (You have already done this correctly.) The Gamma function works for complex numbers, so if your program support complex numbers you should also check your factorials against complex numbers.

screenshot_20180807-115804

Again, refer to the Wolfram article if you need any help. It has specifically defined nCr defined for non-integers with gamma function.

BTW, if you wonder what are the use of non-integers for nCr, consider the binomial expansion of (1+x)^n (where n is not an integer). I don't know for any use of non-integer r, but the web says that some people do use it.

from ncalc.

axkr avatar axkr commented on May 23, 2024

You mean file CustomFunctions.java where the definitions should be:

    Comb(n_, k_):=Binomial(n,k)
    Perm(n_, k_):=Gamma(n+1)/Gamma(k+1)

BTW in you screenshot the input Comb(2.5,) is parsed as Comb(2.5, Null)

from ncalc.

lwchkg avatar lwchkg commented on May 23, 2024

Yes.

BTW, I don't understand why the second string is named BINOMIAL, which is supposed to be a synonym of "combination". I guess you should name that PERMUTATION instead.

Anyway, parsing Comb(2.5,) is parsed as Comb(2.5, Null) is okay to me. With invalid input anything other than crashing is okay. I gave you the screenshot just because it exposes the wrong formula.

from ncalc.

axkr avatar axkr commented on May 23, 2024

Fixed with 3.4.3-beta

from ncalc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.