Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

MATLAB question-factorial

  1. Oct 22, 2011 #1
    So I am trying to plot the birthday problem.

    Number of people vs chance not to have the same birthday.

    I know the analytical form

    [itex] P(n)={\Large\frac{365\cdot 364\cdot 363...(365-n+1)}{365^{n}}}[/itex]

    problem is, matlab is giving me this, when I try to put that into code.

    [PLAIN]http://pokit.org/get/e8cbb0974a4b30d349d554c27ab0f537.jpg [Broken]

    And thats only trying to realise the top part of the fraction.

    I am trying to get this result.

    [URL]http://upload.wikimedia.org/wikipedia/commons/f/ff/Birthdaymatch.png[/URL]

    Source wikipedia.


    Thank you.
     
    Last edited by a moderator: May 5, 2017
  2. jcsd
  3. Oct 22, 2011 #2

    Dr Transport

    User Avatar
    Science Advisor
    Gold Member

    looks like you are not dividing by 365 to the nth power
     
  4. Oct 23, 2011 #3
    Still he is giving me infinity. I think he calculates factorial first, then to the nth, then divides that and still gets infinity
     
  5. Oct 23, 2011 #4

    MATLABdude

    User Avatar
    Science Advisor

    Unfortunately, MATLAB has maxima on both integers and floating point numbers:
    http://www.mathworks.com/help/techdoc/ref/intmax.html
    http://www.mathworks.com/help/techdoc/ref/realmax.html

    I believe that both are exceeded by the calculations that you're trying to make in the numerator and denominator.

    However, I believe that you can do this recursively (i.e. start with n=0, and use this result to generate n=1, use that result to generate n=2, etc.)
    http://en.wikipedia.org/wiki/Recursion_(computer_science)
     
  6. Oct 23, 2011 #5
    My hero <3 Thank you!
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: MATLAB question-factorial
  1. MATLAB question (Replies: 2)

  2. MATLAB question (Replies: 1)

  3. Matlab question (Replies: 2)

  4. Matlab question (Replies: 10)

Loading...