mercredi 15 décembre 2021

My probability program is returning different results when I run the code on different IDES

I have a program that takes a number of colored balls and puts them into a hat.

I then pick N amounts of balls to be drawn out of the hat X amounts of times.

I have a specific combination of colored balls that I am testing for(expected_balls). for example: {'blue': 2, 'green': 3}

def experiment(hat, expected_balls, num_balls_drawn, num_experiments):
    matches = 0

    for experiment in range(num_experiments):
        result = hat.draw(num_balls_drawn)
        result = Counter(result)
        chk = True

        for k, v in expected_balls.items():
            if result[k] < v:
                chk = False
                break

        if chk:
            matches += 1

return (matches/num_experiments)

This code is for a project for class. I wrote the code on Atom and the answer probability matches what the project is looking for. However when I run it on replit, where I submit the project the answer comes out totally different.

Why is the answer different when I run it on two different programs.




Aucun commentaire:

Enregistrer un commentaire