All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Probability
Happy Birthday (3) (Posted on 2006-06-09) Difficulty: 3 of 5
In Happy Birthday, the question was if there are N people in a room, what is the probability that there are at least two people in the room who share a birthday?

What if instead exactly two was required? If there are N people in a room, what is the probability that there are exactly two people in the room who share a birthday?

(Note: Assume leap year doesn't exist, and the birthdays are randomly distributed throughout the year.)

No Solution Yet Submitted by Sir Percivale    
Rating: 4.0000 (3 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
re: solution -- simulation of 20,000 trials of n=19 | Comment 7 of 13 |
(In reply to solution by Charlie)

I ran a program to simulate 20,000 meetings of 19 people. The formula in my solution gives a probability of about .306 of exactly one matching birthday among the 19 people, so you'd expect 20,000 * .306 = 6,120 successes give or take on the order of 100. The program found  6203 successful trials.


RANDOMIZE TIMER
OPEN "bday3.txt" FOR OUTPUT AS #2
FOR trial = 1 TO 20000
 REDIM bday(365)
 found2 = 0
 FOR person = 1 TO 19
  b = INT(RND(1) * 365 + 1)
  bday(b) = bday(b) + 1
  IF bday(b) = 2 THEN found2 = found2 + 1: mno = b
  IF bday(b) = 3 THEN found2 = 10
  PRINT #2, USING "####"; b;
 NEXT
 IF found2 = 1 THEN
   PRINT #2, USING "####"; mno
   ct = ct + 1
 ELSEIF found2 = 0 THEN
   PRINT #2,
 ELSE
   PRINT #2, " x"
 END IF
NEXT
PRINT #2, ct
CLOSE

A sample of the results follows.  The birthdays are given as the day of the year.  An extra number at the end of a row indicates the shared birthday.  An x at the end indicates that more than 2 people had a shared birthday, that is, three or more people with one birthday or two or more separate sharing pairs.

 197 169 326 341   6 209  67 166 188  58 160 330 283 293 174  48 114 286   7
 107 265  37 232 358 108 268 349 228 293  56  43  45 221  37 171 271 353 215  37
 191  94 234  67  60 120 251 182  35  59 207 358 198 140 165 334  78  70 298
 254 180 271  96 123 329 287 215  87 289 206  49  75 116 347 126 261 224 305
 221 155  98 284 116 344   7 320  82 308 255 342 364 341 166 304  20 280  70
  63 236 149  98  64  64 165 172 297 288 106  70  75  68 224 330  94 262  74  64
 309 202 255 334 364 179 362 356  91 247 306 173 327 208 339  52 111 132 273
 132 325  47  45 159 112  80  31  36 330 324 338 107 161  71 193  61   5  51
 349 130 104  20  97 180 336  92 219 354 111 329 184 351 175  65 185 249 132
 240 350 332  66 345  35 271  73 212 137 228 239  59  18 221 351 273 365 311
  63 184 296 155 247 211  37 104  55  89  36 206 279 110 170  28 232 261 141
  31 195 180 325 118 302 306 155  92 252 197 252 213 204 222 263  14 301  62 252
  72 133 293 221  18 223 336 341  94 230  65 173 348 310 310 260 267 107 160 310
 165  87 304 320  76 364 262 359 309 176 124  58 169 164  85 127 198 189 130
  87 123 363 220 260 185 347 208 202   8 203 206 144 104 238 319 339 196 210
 105 129 181  93 314  30  86 186 334 252 124 241 119  45 105 120  10  53  34 105
 196 283  17  73   7  61 219 225 297 331  90 112  30 119 210 306  70  48 365
  98  14 163 268 101 231  21 357 208 336 341 140 188 316 364 271  12 284  50
 351 266 324 171  89 109  64 313 203  58 166 251 118 125 252 314 142 231 217
  29  79 352 155 129 121  20  36 280  16 108 178 183 141 329   8  30 117 107
 185 336  73 269  71  20 166  88  45  67 205 253 254 336  86  93 182 115 328 336
 361 141 225 130 282 294 106 284 153 139 104 324  26 268 198 151 311 207 281
 292 271 362 165  56 269  36  42 164  79 291 312 360 221 323  28  32  90 141
 198  17 204  42 221 127 152 188 276  39 287 268 131 280 231 347 252  27  17  17
 348  71  95 233 356 365 185  66 276 248 234 182 324 102  36 221 140 210  41
  39 185 215  66 300 309 130 278 252 240 342  84 329 155 252  28 108 252 285 x
 133 364  56 348 156 111 353 197 305 307 125 266 212 338 132  29 199  87  24
 106  70 253 281  80 192 213 241  48 110 355 219  85 169 123  84 158 311 165
 101 128  61 198  53 216  60 239 270  92  38 117 198 255 168 156 345 207 318 198
 137 299  18 126 164 132 141 259 175  53 237 116 263 174 273 365 362 348 255
  98  27 108  52 279 126 159  38 356 246 304   6  61 203  22 357 222 185 229
  99   4 258  21  48  85 324  81 276  87 173 335 212 108 353 250 284 159 218
 329  16  52  77  36 217 119 149 197 163 184 338  20 335 100 110  43 150   2
 270  61 150 288  97  72 280 240  41 207  71   7 130  35  17 135 300 143 122
  90  77 149 360 158 179 110 131 148 199 177   7  14  21 355 272 205 238 345
 289 276 106 216 153 154 330  65 236  22 106 135  98 307  91 302  47 294 358 106
   8 229 113 262 115 179 270 226 106 287 166 333 118  68   1 104 154 177 202
 190 109 135 228 143 252 155   6 293 348 148   9  64 320 274 326  36 280 128
 188  75 284 206 140 120 177 174 291 320 260 155 116 178 225 274 169 332   4
 305 246  55 343 126 182 314 188 278  23 355 362  50 282 220  34  42  91  66
 214  74 201 309  43  97 227  32 106 118 361 229 359 195 263 211 344 177 231
 296 219 253 265 225  55 137 334 214 325 171 349 274 285 324 243 356 107  16
 135 219 172 224 220 119  98 201  25 132  44 128 304 297 286 209 288 116 145
 219 129 344 301 239 152 117  84  24 202  17 328 287 172 112 117  57 261 286 117
 190 334 225 287 230 174 185 236 264 159  57 129 324 125 178 164 203 258 194
  63  32  99 225 306 214 192 303 179 362 175 266 287 144 240 100  49 228 143
  21  34  27 114 268   2 284  48 267 325 270 238  77 213 186  11  95  48   6  48
 108 129 157 234  43  18  40 200 297 347 249  96 229 327 340 181  85 156 202
  82 183 177  16  11 192 130 306 238 320 326 260 307  46 346 149 156 219  32
 196 233 151 199 261 255 262 155 346 234  83  54 103 141 358  57 253  31 130
 321  80 245 125 336 130 263  16 189 258 183 168  90 311 117 177 355 187  33
  70  19 335  61 120 291 172 152  37  56 226 204  65 250   1 265 350 274 310
 113  32 354 221  10  83 340 305  92  23  48 129 217 212  68 229 267 208 103
 146 173 145 322 220  40   7 247 173 354  93 287 354  96 103  78 141  56 158 x
 202  97  32  65 340 192 134 152  83 312 361 357 186 129 260 145 272 155 143
 334 278 334 204 278 159 182  87 242  56 121  15 222 187 338 176 314 102 111 x
 205  84 214 139 217 215 140 222 105 230  56 317  24 325 310 220 237   5  38
  80 325  95 253 263 308 104  80 218  35  51  29 355 124 202 244 361  76 157  80
 298 165 131 231 186 260 285 359 307 300 146 197  73 333 321  38 270 305 263
 362  29  22 212  18  88 297 311 334 321 168 177 195 258  58  29 340  81 270  29
  73  80 236 312 352 318  47 131 313  83  74 349 302  97 181  36 218 227 244
  39  94 310 228 210  29 341 353   5 222  22 255 267 357 232  62 357 182 197 357
 107 123 176 240 360 134 116 231 321 179 292 324  97  48 259 323 114  42 237
 240 183 109  36 201 124 171 280  94 117 174  59  28  38 231 150 158 364 127
 127 229 231   7 307 320 344  63 135 203 127 315 310 269  78 108 259 340 204 127
 268  83  44 365 230  39   6 353   9 108 211  51  65  28 284  60 169 140 226
 221 186 143 144  50 218 123  75   5 103 217 269 276 111   6  92  44 263 180
 322 104 108 292  46 118  51 241 226 322 221  29  54  58 155 340 338  32  36 322
 280  34 294 197 333 180 125 352 287 251 213  11 173  78 171  83 209  40 164
 189  92 248  68  84 214 181 185  72  53 251 221  55 292 158 181 129 299 270 181
 263 181  71 166 108 306  76 196 336 218 101 205 157 214   4 179 179  42 205 x
 253 205  41  69  75  35 196  31  92 362   1 172 365 109 248 328 215  60 156
 311 141  18  69 205 186  61 231  34 213  71  15 241 281  81 163  80   6 352
  12 104 213  72 280   8 295 176 108 202  43  36  28 204 106  95 287  32 359
 208 342 238 179 258 288 196 277 147 176 143 237 226 154  20 168   8 339 230
 255 247  45 298  26 365  26 177 285 351  61 187   7 198 284 309 272 159  53  26
 310 251   1 184 315 231 169 178  17 334 135 281 164  72 106 347 125 177 283
 251 289 143 202  41 179 236 362 161 304 319 287 323  93 217 340 288 289 183 289
 331   4 336 355  54 209 234 306 266 201 288 142 122  77 230 238 164 148 246
 327 301  74 280 149  60 290 149 184  35 226 120 286 130 281 121 245  95 225 149
 130  56 145 259 297 297 211 337  58  33  19 301 265 292 345 127 294 323 356 297
 237 352 164 146 102 232   5  78 200 342  13 225  66 276 245 257  76  25 288
 153  36 194  89 280  57 109 141  96  57  38 303 229  86 213 169 274  17 316  57
 264 325  46 143  38  45 201 362 338  19 302  78 127 277  10 332 234   1  65
  18 252 249 331 298 283 192 122 335 210  20  74  65 160 287 104 129 329 249 249
   2  81 163 310 127 330 191 184 360 162 296  61 245 232 271  40 323  38  93
  28 264 229 298  80  12 265 254 115 295 174 169  74 302 220 279 184 202 291
 125 206  93 107 105 241 152 260 208 165 135  43 291 250  68 134  81  55 297
 243   9 320 173 153 299 216 108 107 151 154  80 199 306 308  43 224 219 326
  72 341  77 224 235   7 341 277 184 288 299 275 302  57 349 322  23 305 365 341
 275 254 162 337   2  49 295  16  90 312 205 103  99 290 350 252 183 360 350 350
  72 258 167 203 233 341 130 128   8 268 132 140  14 218 111  78 300 242  26
  88 360 249 272 107 316  72 360 162  16   9 249  36  43 339 302 117 261 219 x
 249 149 275 307  53 263 351   9 147 277 236 293 299 183 256  20  27 352 320
  31 204  16 109  31   3 216  83 305 145 270  28 240  31 176 248 221  73 182 x
 295 345 101  87 338 303  57  89  80  99  45 267 311 122 106 152 179 216  90
 217  21 304 345 171 276   4 309 267 123 161 110 138 220  97  74 294  69  55
 315  46 208  87  62 274 117 129 351  79 236 165 248  96  50 120  93  61 286
 207  91 113  91 272  87   4 139 325 169 225 354  62 263 293 286 314 181  65  91
 297 200 129  36 293 207 215 276   1 264  40 178  71  85 208 137 348 340 286
  22  62 264 125 302 292 107 187 339 326  17 140  62 315 118  92 264 360 310 x
  94  82  65 157 104  32   5 334  35  30 358 147 265  64   1 247  43 217  76
 340   7  60 340 256  42 322 365  33 158 272  83  73 351 303  73 310 206 227 x
 101 190  38 215 314 206 307   6 333 239  27  28 265 177   7  60 338 268 355
 173 275  92 248 299 205 193 360 265 219 143 267 274   5 348 321  19  45 301
 334  87 339 205 178 156 323 133 108 213 333  16  85  35 240  78 282 220   7
 270 223  26 330 168 206  46  93  44 255 229 110 215 265 181  30 111 235 293
  80 356 231  29 335 199  66 332  88 139 180 275 229 270  44   7 237 169 309
 148  12 339 308 171 338  97  20 164 148 288 301 132  94 264 294 113 356  50 148
  36  25  14  60 228 337 154 159 289 265 133 294 131  90 138 104 219 268 192

  Posted by Charlie on 2006-06-09 16:53:44
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (6)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information