Interactive PowerBasic Forum

IT-Consultant: Charles Pegge => OxygenBasic Examples => Topic started by: Charles Pegge on February 16, 2025, 09:56:04 AM

Title: Chances / Probability
Post by: Charles Pegge on February 16, 2025, 09:56:04 AM

macro Chances as float(r, n,p)
==============================
'n nomber of opportunities or trials
'p probability of a single coincidence
float np=1.0-p
r=pow(np,n)
r=1.0-r
end macro
'
'TEST
'going to a party with 50 guests.
'what is the chances that someone at the
'party has the same birthday as you?
print str(chances(50, 1/365)*100,0) "%"  '13%
'also
print str(chances(300, 1/365)*100,0) "%" '56%

Title: Re: Chances / Probability
Post by: Nicola on December 25, 2025, 01:04:13 AM
I asked Copilot, and it told me that if I and 49 other people are invited to the same party, the probability that there is another person with the same birthday as mine is 12.5%.
Title: Re: Chances / Probability
Post by: Charles Pegge on December 25, 2025, 11:02:52 AM

It is 1 - (the probability of not having the same birthday as any single person) ^ 49


1.0 - pow( (364/365), 49)
Title: Re: Chances / Probability
Post by: Nicola on December 25, 2025, 02:15:47 PM
💪