Trying to find the smallest # of people needed to "enter" a room to have a probability of at least 50% for two people sharing the same birthday, using the monte carlo method (the well known solution is 23 people, but I cant seem to find my errors in logic, or implementation)
Birthday Paradox in Python with monte carlo method?
597 Views Asked by astralled At
1
There are 1 best solutions below
Related Questions in PYTHON
- How to store a date/time in sqlite (or something similar to a date)
- Instagrapi recently showing HTTPError and UnknownError
- How to Retrieve Data from an MySQL Database and Display it in a GUI?
- How to create a regular expression to partition a string that terminates in either ": 45" or ",", without the ": "
- Python Geopandas unable to convert latitude longitude to points
- Influence of Unused FFN on Model Accuracy in PyTorch
- Seeking Python Libraries for Removing Extraneous Characters and Spaces in Text
- Writes to child subprocess.Popen.stdin don't work from within process group?
- Conda has two different python binarys (python and python3) with the same version for a single environment. Why?
- Problem with add new attribute in table with BOTO3 on python
- Can't install packages in python conda environment
- Setting diagonal of a matrix to zero
- List of numbers converted to list of strings to iterate over it. But receiving TypeError messages
- Basic Python Question: Shortening If Statements
- Python and regex, can't understand why some words are left out of the match
Related Questions in PYTHON-3.X
- SQLAlchemy 2 Can't add additional column when specifying __table__
- Writes to child subprocess.Popen.stdin don't work from within process group?
- Platform Generation for a Sky Hop clone
- What's the best way to breakup a large test in pytest
- chess endgame engine in Python doesn't work perfectly
- Function to create matrix of zeros and ones, with a certain density of ones
- how to create a polars dataframe giving the colum-names from a list
- Django socketio process
- How to decode audio stream using tornado websocket?
- Getting website metadata (Excel VBA/Python)
- How to get text and other elements to display over the Video in Tkinter?
- Tkinter App - My Toplevel window is not appearing. App is stuck in mainloop
- Can I use local resources for mp4 playback?
- How to pass the value of a function of one class to a function of another with the @property decorator
- Python ModuleNotFoundError for command line tools built with setup.py
Related Questions in MONTECARLO
- MCNP 6 - Doubts about cells
- Dual y-axis of probability histogram and cumulative probability across the histogram all in one plot
- Monte Carlo simulation Lotto Germany
- How can I easily parallelize my Monte Carlo simulations?
- Monte carlo method for uncertainty
- Monte Carlo Example using Accept Reject Method
- Monte Carlo 4D integral with variable limit
- Correlation matrix shrinkage causes matrix multiplication error for monte carlo simulation
- Why do the samplers not behave the same when sampled on there own?
- Missing plot in gamma distribution with monte carlo approximation
- Approximation of the area under the curve of the Gamma density far from the the theoretical value
- Why my Monte Carlo estimation of pi plot is empty?
- Need advice on how to understand C++ code for Monte Carlo Pricing Barrier Call Option
- Numba implementation for Monte-Carlo simulation
- Metropolis-Hastings algorithm in a lattice
Related Questions in BIRTHDAY-PARADOX
- How to modify the Birthday Problem to answer the probability of 3, 4, 5 or more people in a room having the same birthday
- How was there no collision among 50,000 random 7-digit hex strings? (The Birthday Problem)
- Is my approach valid for showing that my algorithm (usage of python's random.sample) is NOT susceptible to the Birthday Problem?
- find probability of n people in a class of x share the same birthday using monte carlo simulation in java
- How to deal with large numbers from specific range?
- How to Resolve For Loop Error While Running the Birthday Paradox
- Some questions about bday paradox results
- birthday paradox function in R
- Too frequent Random Byte Collision
- How to tackle the Birthday Paradox Problem in Python?
- Speed up processing 32 bit numbers in combinations (k from n)
- Birthday Paradox count keeps growing in python
- What's wrong with this code that tries to calculate the birthday paradox with ArrayLists?
- Monte Carlo simulation of Birthday paradox in python 3
- Generate small UID with uniqueness
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
The error is in expressing how you look for an existing date:
Let's just take the case where you've already found dates 3 and 15, and you just drew another 15 birthday. This check statement evaluates as
This is
False! The expression on the right has one element, a list. There is no way that an integer (15) and a list ([3, 15]) can be equal, so the check will always fail. Instead, use theincheck as seen in your tutorials:Output:
Yes, you have a couple more errors in your code. You printed a counter instead of the duplicates date, and you reset
counterevery time through the loop, so your final proportion is always dividing by1.Once you fix those, the output will look like
Finally, your problem description says that you exit the loop when you find a duplicate. As the above output shows, this is not what you're doing. You will need a
breakstatement for that.