def test_prob_experiment(self): hat = prob_calculator.Hat(blue=3, red=2, green=6) probability = prob_calculator.experiment(hat=hat, expected_balls={ "blue": 2, "green": 1 }, num_balls_drawn=4, num_experiments=1000) actual = probability expected = 0.272 self.assertAlmostEqual( actual, expected, delta=0.01, msg='Expected experiemnt method to return a different probability.' ) hat = prob_calculator.Hat(yellow=5, red=1, green=3, blue=9, test=1) probability = prob_calculator.experiment(hat=hat, expected_balls={ "yellow": 2, "blue": 3, "test": 1 }, num_balls_drawn=20, num_experiments=100) actual = probability expected = 1.0 self.assertAlmostEqual( actual, expected, delta=0.01, msg='Expected experiment method to return a different probability.' )
def test_experiment(self): bucket = prob_calculator.Hat(red=4, black=4) ex = prob_calculator.experiment(bucket, expected_balls={'red': 1, 'black': 1}, num_balls_drawn=2, num_experiments=1000) actual = ex expected = 0.5714 self.assertAlmostEqual(actual, expected, delta=0.02, msg='Expected a different probability.')
# This entrypoint file to be used in development. Start by reading README.md import prob_calculator from unittest import main hat = prob_calculator.Hat(blue=4, red=2, green=6) probability = prob_calculator.experiment(hat=hat, expected_balls={ "blue": 2, "red": 1 }, num_balls_drawn=4, num_experiments=2000) print("Probability:", probability) # Run unit tests automatically main(module='test_module', exit=False)
# This entrypoint file to be used in development. Start by reading README.md import prob_calculator from unittest import main hat = prob_calculator.Hat(blue=4, red=2, green=6, black=10) probability = prob_calculator.experiment(hat=hat, expected_balls={ "green": 1, "blue": 1, "black": 10 }, num_balls_drawn=15, num_experiments=10000) print("Probability:", probability) # Run unit tests automatically main(module='test_module', exit=False)
from prob_calculator import Hat, experiment from unittest import main hat = Hat(black=6, red=4, green=3) probability = experiment(hat=hat, expected_balls={ 'red': 2, 'green': 1 }, num_balls_drawn=5, num_experiments=2000) print(probability) # main(module='test_module',exit=False)
import prob_calculator hat1 = prob_calculator.Hat(black=6, red=4, green=3) probability = prob_calculator.experiment(hat=hat1, expected_balls={ "red": 2, "green": 1 }, num_balls_drawn=5, num_experiments=10000) print("Probability: ", probability)
# This entrypoint file to be used in development. Start by reading README.md import prob_calculator from unittest import main hat = prob_calculator.Hat(blue=1, red=1) probability = prob_calculator.experiment( hat=hat, expected_balls={"red": 1}, num_balls_drawn=1, num_experiments=3000) print("Probability:", probability) # Run unit tests automatically main(module='test_module', exit=False)
import prob_calculator as pc hat = pc.Hat(red=5, orange=4, black=1, blue=1, pink=2, striped=9) color, amount = hat.unpack() print('List of balls : \n') for i, j in zip(color, amount): print(i, j) hat, \ expected_balls, \ num_balls_drawn, \ num_experiments, \ prob = pc.experiment(hat=hat, expected_balls={"red":2,"orange":3, 'striped':1}, num_balls_drawn=6, num_experiments=101) print('\nExpected balls: ', expected_balls) print('Number balls drawn: ', num_balls_drawn) print('Number experiments: ', num_experiments) print("Probability: ", prob)
import prob_calculator from unittest import main hat = prob_calculator.Hat(blue=3, red=2, green=6) probability = prob_calculator.experiment(hat=hat, expected_balls={ "blue": 2, "green": 1 }, num_balls_drawn=4, num_experiments=1000) # print(len(hat.contents)) print("Probability:", probability) hat = prob_calculator.Hat(yellow=5, red=1, green=3, blue=9, test=1) # print(len(hat.contents)) probability = prob_calculator.experiment(hat=hat, expected_balls={ "yellow": 2, "blue": 3, "test": 1 }, num_balls_drawn=20, num_experiments=100) print("Probability:", probability) # Run unit tests automatically # main(module='test_module', exit=False)
#!/usr/bin/env python3 import prob_calculator from unittest import main hat = prob_calculator.Hat(blue=4, red=2, green=6) probability = prob_calculator.experiment( hat=hat, balls_to_draw={"blue": 2, "red": 1}, num_balls_drawn=4, num_experiments=3000) print("Probability:", probability) # Run unit tests automatically main(module='test_module', exit=False)
# This entrypoint file to be used in development. Start by reading README.md import prob_calculator from prob_calculator import experiment from unittest import main hat = prob_calculator.Hat(yellow=5, red=1, green=3, blue=9, test=1) #print(hat.draw(2)) #print(hat.contents) lol = {"red": 6, "green": 3} print(experiment(hat, {"yellow": 2, "blue": 3, "test": 1}, 20, 100)) # Run unit tests automatically main(module='test_module', exit=False)