{"id":19427937,"url":"https://github.com/gappeah/probability-calculator","last_synced_at":"2025-02-25T05:22:49.605Z","repository":{"id":191433537,"uuid":"684661914","full_name":"gappeah/probability-calculator","owner":"gappeah","description":"As part of my five projects for freeCodeCamp Scientific Computing with Python","archived":false,"fork":false,"pushed_at":"2023-08-29T15:51:38.000Z","size":5,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-07T19:44:43.700Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gappeah.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-08-29T15:44:02.000Z","updated_at":"2024-09-12T11:00:41.000Z","dependencies_parsed_at":"2023-08-29T23:13:04.292Z","dependency_job_id":null,"html_url":"https://github.com/gappeah/probability-calculator","commit_stats":null,"previous_names":["gappeah/probability-calculator"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gappeah%2Fprobability-calculator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gappeah%2Fprobability-calculator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gappeah%2Fprobability-calculator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gappeah%2Fprobability-calculator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gappeah","download_url":"https://codeload.github.com/gappeah/probability-calculator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240607636,"owners_count":19828272,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T14:13:20.703Z","updated_at":"2025-02-25T05:22:49.563Z","avatar_url":"https://github.com/gappeah.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"I created a Hat class in prob_calculator.py that takes a variable number of arguments that specify the number of balls of each colour that are in the hat. I also created a draw method that accepts an argument indicating the number of balls to draw from the hat. This method removes balls at random from contents and returns those balls as a list of strings. The balls should not go back into the hat during the draw, similar to an urn experiment without replacement. If the number of balls to draw exceeds the available quantity, return all the balls.\n\nI also created an experiment function in prob_calculator.py that accepts the following arguments:\n\n* hat: A hat object containing balls that should be copied inside the function.\n* expected_balls: An object indicating the exact group of balls to attempt to draw from the hat for the experiment.\n* num_balls_drawn: The number of balls to draw out of the hat in each experiment.\n* num_experiments: The number of experiments to perform. (The more experiments performed, the more accurate the approximate probability will be.)\n\nThe experiment function returns a probability.\n\nFor example, if I wanted to determine the probability of getting at least two red balls and one green ball when I draw five balls from a hat containing six black, four red, and three green. To do this, I would perform N experiments, count how many times M I get at least two red balls and one green ball, and estimate the probability as M/N. Each experiment consisted of starting with a hat containing the specified balls, drawing several balls, and checking if I got the balls I was attempting to draw.\n\nHere is what I would call the experiment function based on the example above with 2000 experiments:\n\n```python\nhat = Hat(black=6, red=4, green=3)\nprobability = experiment(hat=hat,\n                  expected_balls={\"red\":2,\"green\":1},\n                  num_balls_drawn=5,\n                  num_experiments=2000)\n```\n\nSince this is based on random draws, the probability will be slightly different each time the code is run.\n\nI wrote my code in prob_calculator.py. For development, I used main.py to test my code. Click the \"run\" button and main.py will run.\n\nThe unit tests for this project are in test_module.py. We imported the tests from test_module.py to main.py for convenience. The tests would run automatically whenever I hit the \"run\" button.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgappeah%2Fprobability-calculator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgappeah%2Fprobability-calculator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgappeah%2Fprobability-calculator/lists"}