What is the probability that two persons have I same birthday II different birthday?

One way to find the probability of no birthday match in a room with $n=25$ people is shown in the Wikipedia link of my first Comment. Here is a slightly different way to write it:

$$P(\text{No Match}) = \frac{{}_{365}P_{25}}{365^{25}} = \prod_{i=0}^{24}\left(1 - \frac{i}{365}\right) = 0.4313.$$

In R, this can be evaluated as follows. [In R, 0:24 is a list of the integers from 0 through 24; similarly for other uses of :.]

prod((365:(365-24))/365)
[1] 0.4313003
prod(1 - (0:24)/365)
[1] 0.4313003
prod(365:341)/365^25
[1] 0.4313003

So $P(\text{At least one match}) = 1 - 0.4313 = 0.5687.$

You can use R to make the first figure in the Wikipedia article as shown below. The green line shows that for 23 people or more the probability of at least one birthday match exceeds $1/2.$

n = 1:60
p = numeric(60)
for (i in n) {
  q = prod(1 - (0:(i-1))/365)
  p[i] = 1 - q
  }

plot(n, p)
  lines(c(0,23,23), c(.5,.5,0), col="green2")

What is the probability that two persons have I same birthday II different birthday?

Some people are surprised that matches occur with such high probability. Maybe they are thinking at it would take 366 people in a room to be sure of a match. But the graph shows that probability does not increase linearly with room size. So it is "nearly sure" (probability 0.9941) to get a match in a room of only 60 people. And the probability of at least one match is above 1/2 in a room of 23 people.

Here is a table of some of these 60 probabilities (truncated at 30):

cbind(n, p)
       n           p
 [1,]  1 0.000000000
 [2,]  2 0.002739726
 [3,]  3 0.008204166
 [4,]  4 0.016355912
 [5,]  5 0.027135574
 [6,]  6 0.040462484
 [7,]  7 0.056235703
 [8,]  8 0.074335292
 [9,]  9 0.094623834
[10,] 10 0.116948178
[11,] 11 0.141141378
[12,] 12 0.167024789
[13,] 13 0.194410275
[14,] 14 0.223102512
[15,] 15 0.252901320
[16,] 16 0.283604005
[17,] 17 0.315007665
[18,] 18 0.346911418
[19,] 19 0.379118526
[20,] 20 0.411438384
[21,] 21 0.443688335
[22,] 22 0.475695308
[23,] 23 0.507297234  # first to exceed 1/2
[24,] 24 0.538344258
[25,] 25 0.568699704
[26,] 26 0.598240820
[27,] 27 0.626859282
[28,] 28 0.654461472   
[29,] 29 0.680968537
[30,] 30 0.706316243
 ...
[60,] 60 0.994122661

Notes: I agree with @Ben (+1) that your equation doesn't work to get the probability of a match between two randomly chosen people. however, suppose you're among the 25 people in a room, then with probability $1 -\left(\frac{364}{365}\right)^{24} = 0.0637$ at least one other person in the room will match your birthday.

Thus, another wrong 'intuitive' approach to the main birthday problem above is to confuse the probability someone will match your birthday with the larger probability that some two (or more) people will have matching birthdays. (Among 25 people there are ${25 \choose 2} = 300$ pairs of people who may have matching birthdays.)

Finally, this Q&A shows a method of simulating the probability of a birthday match. With a slight modification, that method can also be used to find the expected number of matches.

Video transcript

One of you all sent a fairly interesting problem, so I thought I would work it out. The problem is I have a group of 30 people, so 30 people in a room. They're randomly selected 30 people. And the question is what is the probability that at least 2 people have the same birthday? This is kind of a fun question because that's the size of a lot of classrooms. What's the probability that at least someone in the classroom shares a birthday with someone else in the classroom? That's a good way to phrase as well. This is the same thing as saying, what is the probability that someone shares with at least someone else. They could share it with 2 other people or 4 other people in the birthday. And at first this problem seems really hard because there's a lot of circumstances that makes this true. I could have exactly 2 people have the same birthday. I could have exactly 3 people have the same birthday. I could have exactly 29 people have the same birthday and all of these make this true, so do I add the probability of each of those circumstances? And then add them up and then that becomes really hard. And then I would have to say, OK, whose birthdays and I comparing? And I would have to do combinations. It becomes a really difficult problem unless you make kind of one very simplifying take on the problem. This is the opposite of-- well let me draw the probability space. Let's say that this is all of the outcomes. Let me draw it with a thicker line. So let's say that's all of the outcomes of my probability space. So that's 100% of the outcomes. We want to know-- let me draw it in a color that won't be offensive to you. That doesn't look that great, but anyway. Let's say that this is the probability, this area right here-- and I don't know how big it really is, we'll figure it out. Let's say that this is the probability that someone shares a birthday with at least someone else. What's this area over here? What's this green area? Well, that means if these are all the cases where someone shares a birthday with someone else, these are all the area where no one shares a birthday with anyone. Or you could say, all 30 people have different birthdays. This is what we're trying to figure out. I'll just call it the probability that someone shares. I'll call it the probability of sharing, probability of s. If this whole area is area 1 or area 100%, this green area right here, this is going to be 1 minus p of s. This is going to be 1 minus p of s. Or if we said that this is the probability-- or another way we could say it, actually this is the best way to think about it. If this is different, so this is the probability of different birthdays. This is the probability that all 30 people have 30 different birthdays. No one shares with anyone. The probability that someone shares with someone else plus the probability that no one shares with anyone-- they all have distinct birthdays-- that's got to be equal to 1. Because we're either going to be in this situation or we're going to be in that situation. Or you can say they're equal to 100%. Either way, 100% and 1 are the same number. It's equal to 100%. So if we figure out the probability that everyone has the same birthday we could subtract it from 100. So let's see. We could we just rewrite this. The probability that someone shares a birthday with someone else, that's equal to 100% minus the probability that everyone has distinct, separate birthdays. And the reason why I'm doing that is because as I started off in the video, this is kind of hard to figure out. You know, I can figure out the probability that 2 people have the same birthday, 5 people, and it becomes very confusing. But here, if I wanted to just figure out the probability that everyone has a distinct birthday, it's actually a much easier probability to solve for. So what's the probability that everyone has a distinct birthday? So let's think about it. Person one. Just for simplicity, let's imagine the case that we only have 2 people in the room. What's the probably that they have different birthdays? Let's see, person one, their birthday could be 365 days out of 365 days of the year. You know, whenever their birthday is. And then person two, if we wanted to ensure that they don't have the same birthday, how many days could person two be born on? Well, it could be born on any day that person one was not born on. So there are 364 possibilities out 365. So if you had 2 people, the probability that no one is born on the same birthday-- this is just 1. It's just going to be equal to 364/365. Now what happens if we had 3 people? So first of all the first person could be born on any day. Then the second person could be born on 364 possible days out of 365. And then the third person, what's the probability that the third person isn't born on either of these people birthdays? So 2 days are taken up, so the probability is 363/365. You multiply them out. You get 365 times 36-- actually I should rewrite this one. Instead of saying this is 1, let me write this as-- the numerator is 365 times 364 over 365 squared. Because I want you to see the pattern. Here the probability is 365 times 364 times 363 over 365 to the third power. And so, in general, if you just kept doing this to 30, if I just kept this process for 30 people-- the probability that no one shares the same birthday would be equal to 365 times 364 times 363-- I'll have 30 terms up here. All the way down to what? All the way down to 336. That'll actually be 30 terms divided by 365 to the 30th power. And you can just type this into your calculator right now. It'll take you a little time to type in 30 numbers, and you'll get the probability that no one shares the same birthday with anyone else. But before we do that let me just show you something that might make it a little bit easier. Is there any way that I can mathematically express this with factorials? Or that I could mathematically express this with factorials? Let's think about it. 365 factorial is what? 365 factorial is equal to 365 times 364 times 363 times-- all the way down to 1. You just keep multiplying. It's a huge number. Now, if I just want the 365 times the 364 in this case, I have to get rid of all of these numbers back here. One thing I could do is I could divide this thing by all of these numbers. So 363 times 362-- all the way down to 1. So that's the same thing as dividing by 363 factorial. 365 factorial divided by 363 factorial is essentially this because all of these terms cancel out. So this is equal to 365 factorial over 363 factorial over 365 squared. And of course, for this case, it's almost silly to worry about the factorials, but it becomes useful once we have something larger than two terms up here. So by the same logic, this right here is going to be equal to 365 factorial over 362 factorial over 365 squared. And actually, just another interesting point. How did we get this 365? Sorry, how did we get this 363 factorial? Well, 365 minus 2 is 363, right? And that makes sense because we only wanted two terms up here. We only wanted two terms right here. So we wanted to divide by a factorial that's two less. And so we'd only get the highest two terms left. This is also equal to-- you could write this as 365 factorial divided by 365 minus 2 factorial 365 minus 2 is 363 factorial and then you just end up with those two terms and that's that there. And then likewise, this right here, this numerator you could rewrite as 365 factorial divided by 365 minus 3-- and we had 3 people-- factorial. And that should hopefully make sense, right? This is the same thing as 365 factorial-- well 365 divided by 3 is 362 factorial. And so that's equal to 365 times 364 times 363 all the way down. Divided by 362 times all the way down. And that'll cancel out with everything else and you'd be just left with that. And that's that right there. So by that same logic, this top part here can be written as 365 factorial over what? 365 minus 30 factorial. And I did all of that just so I could show you kind of the pattern and because this is frankly easier to type into a calculator if you know where the factorial button is. So let's figure out what this entire probability is. So turning on the calculator, we want-- so let's do the numerator. 365 factorial divided by-- well, what's 365 minus 30? That's 335. Divided by 335 factorial and that's the whole numerator. And now we want to divide the numerator by 365 to the 30th power. Let the calculator think and we get 0.2936. Equals 0.2936. Actually 37 if you rounded, which is equal to 29.37%. Now, just so you remember what we were doing all along, this was the probability that no one shares a birthday with anyone. This was the probability of everyone having distinct, different birthdays from everyone else. And we said, well, the probability that someone shares a birthday with someone else, or maybe more than one person, is equal to all of the possibilities-- kind of the 100%, the probability space, minus the probability that no one shares a birthday with anybody. So that's equal to 100% minus 29.37%. Or another way you could write it as that's 1 minus 0.2937, which is equal to-- so if I want to subtract that from 1. 1 minus-- that just means the answer. That means 1 minus 0.29. You get 0.7063. So the probability that someone shares a birthday with someone else is 0.7063-- it keeps going. Which is approximately equal to 70.6%. Which is kind of a neat result because if you have 30 people in a room you might say, oh wow, what are the odds that someone has the same birthday as someone else? It's actually pretty high. 70% of the time, if you have a group of 30 people, at least 1 person shares a birthday with at least one other person in the room. So that's kind of a neat problem. And kind of a neat result at the same time. Anyway, see you in the next video.

What is the probability that the two friends have I the same birthday II different birthdays ignoring a leap year?

Hence, the probability that two friends have different birthdays = 1 – 1365=364365.

What is the probability of two people sharing a birthday?

The chance of: two people sharing a birthday would be 1 - (364/365), or 0.3%, or 1 in 370. three people sharing a birthday would be 1 - ((364/365)(363/365)), or 0.8%, or 1 in 122.