Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6611213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:56:30+00:00 2026-05-25T19:56:30+00:00

Working with python 2.7. The following code allows me to input the winning percentage

  • 0

Working with python 2.7.

The following code allows me to input the winning percentage of two teams (WP_1 and WP_2) a number of wins (k) and determine given the two team’s winning percentages, the probability that team one will have more wins at the end of the season (Playoff_Probability):

def PlayoffProb(WP_1, k, WP_2):
    TProb_2 = 0
    p = float(WP_1)/1000
    q = float(WP_2)/1000
    n = 162.0
    G = math.factorial(n)/(math.factorial(k)*math.factorial(n-k))
    Prob = G*(p**k)*((1-p)**(n-k))
    for c in range(0, k):
        G_2 = math.factorial(n)/(math.factorial(c)*math.factorial(n-c))
        Prob_2 = G_2*(q**c)*(1-q)**(n-c)
        TProb_2 += Prob_2
    Playoff_Probability = Prob*TProb_2
    print Playoff_Probability
    print TProb_2

But what would be a lot easier is if the function could be written recursively so that it would perform the same operation over every possible value of k and return the total probability of ending the season with more wins (which I believe should be given by the Playoff_Probability for each value run through the function of k, which I’ve tried to set equal to Total_Playoff_Probability).

I’ve tried the following code, but I get a TypeError telling me that ‘float’ object is not callable at the return Total_Playoff_Probability step. I’m also not at all sure that I’ve set up the recursion appropriately.

def PlayoffProb2(WP_1, k, WP_2):
    TProb_2 = 0
    Total_Playoff_Probability = 0
    p = float(WP_1)/1000
    q = float(WP_2)/1000
    n = 162.0
    G = math.factorial(n)/(math.factorial(k)*math.factorial(n-k))
    Prob = G*(p**k)*((1-p)**(n-k))
    for c in range(0, k):
        G_2 = math.factorial(n)/(math.factorial(c)*math.factorial(n-c))
        Prob_2 = G_2*(q**c)*(1-q)**(n-c)
        TProb_2 += Prob_2
    Playoff_Probability = Prob*TProb_2
    Total_Playoff_Probability += Playoff_Probability 
    if k == 162:
        return Total_Playoff_Probability
    else:
        return PlayoffProb2(WP_1, k+1, WP_2)

Any help would be greatly appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T19:56:31+00:00Added an answer on May 25, 2026 at 7:56 pm
      return Total_Playoff_Probability(WP_1, k+1, WP_2)
    

    I think you meant

      return PlayoffProb2(WP_1, k+1, WP_2)
    

    You’ve got that error because you are trying to treat a floating point number as a function. Obviously, that doesn’t compute.

    EDIT

    Actually, it should be:

       return Total_Playoff_Probability + PlayoffProb2(WP_1, k+1, WP_2)
    

    As it is, you aren’t doing anything with Total_Playoff_Probability after you calculate it. If k != 167, you just return the value for k+1.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am using python 2.5.2 . The following code not working. def findValue(self, text,
I have the following code written to make my lazy second CPU core working.
I am currently running the following code based on Chapter 12.5 of the Python
i am working on a regex match function in python. i have the following
I'm working with Python 2.7 and PyGTK 2.24. I am working with the following
When running the following code, which is an easy problem, the Python interpreter works
With python 2.7 the following code computes the mD5 hexdigest of the content of
I have the following code in Python: for i in range(4): if self.start ==
I have the following fully functional, working code: import urllib.request import zipfile url =
In windows XP, python 2.5 and 2.6 I tested the following code: import urllib2

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.