In this video , Michael Aranda states that "one in 5 Americans either has had bed bugs or knows someone who has." Assume the following about the population of USA:
If the expected number of people infected with bed bugs is $N$ , find $25 \lfloor \frac{N1}{25} \rfloor$ .
Hint: The answer is between 100,000 and 200,000.
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
nonjavascript version of this page
. We're sorry about the hassle.
Hmm, I'm a little skeptical of this solution. How did you know that this method would work for the given constraint that every person $n$ knows everyone from $n250$ to $n+250$ ? If I had given a different construction, the number of people infected does change.
Log in to reply
This method works as long as each person knows exactly 501 people (which may include themself). And of course, you can generalize it so each person knows the same constant number of people. The reason it works is because each person is infected independently from another. If infection is not independent (e.g. infection is more likely in rural areas), or if the numbers of known acquaintances are different among people (e.g. more people know each other in office than in farms), then the solution doesn't work and indeed you might need to use simulation.
Let's say $B_n$ is the event that person $n$ is infected, and $K_n$ is the event that person $n$ knows anyone that's infected (which may be themself). In other words, if $S_n$ is the set of people that $n$ knows, then $K_n = \bigcup_{i \in S_n} B_i$ . Then by De Morgan's laws, $\overline{K_n} = \bigcap_{i \in S_n} \overline{B_i}$ , so
$\displaystyle P( \overline{K_n} ) = P \left( \bigcap_{i \in S_n} \overline{B_i} \right)$
But since we assumed $B_p$ 's are all independent, we have
$\displaystyle P( \overline{K_n} ) = \prod_{i \in S_n} P( \overline{B_i} )$
Finally, just plug in $P(\overline{K_n}) = 1  P(K_n) = 1  \frac{1}{5} = \frac{4}{5}$ . Call $P(B_i) = p$ , then $P(\overline{B_i}) = 1  P(B_i) = 1p$ . Since $S_n = 501$ , the RHS becomes $(1p)^{501}$ . And of course, by linearity of expectation, $N$ is simply $326000000 \cdot p$ , so once we have $p$ , we have $N$ .
The full code is posted below.
If your computer can handle it, you could make an array with 326000000 elements and generate N random numbers and see how many people know the infected. However, this method was incredibly slow for me (took 20 mins per simulation). Here is an alternative method that takes 0.1 seconds per simulation (on CS50).
1) generate an array (call it bugArray) of N random numbers, quick sort the array.
2) for all elements in bugArray check bugArray[i]=bugArray[i + 1]
Note: we could just generate random numbers to replace the duplicate elements and then insertion sort the new bugArray, but that actually takes a while. Steps 36 are only to speed up this process sort.
3) for each i where step two is true, set duplicatePlaces[k] = i and set duplicateValues[k]= random number() mod 326000000.
4) quick sort duplicateValues
5) insert, in order, each element duplicateValues[k] into bugArray[duplucatePlaces[k]].
6) insertion sort the new bugArray.
7) repeat steps 26 until there are no duplicates
Here comes a little math. Remember, bugsArray[2]=10 means that person number 10 has bedbugs and that subject has the 3rd smallest number (since arrays start at 0). For simplicities sake, assume the population of America is 35, 7 people are infected, and each person p knows the 4 people whose numbers are Between p+2 and p2. If someone knows more than one person with bed bugs, that person only increases the count by 1.
bugArray[0] = 1; bugArray[1]= 7: bugArray[2]=9; bugArray[7]=15; bugArray[4]=19; bugArray[5]=25; bugArray[6]=30.
If a 1 represents someone who has bed bugs or knows someone else with bed bugs, but not both, and a 2 represents an overlap (someone who knows two or more people with bed bugs or has bed bugs and knows someone else with bed bugs), then the subjects, in order, would look like this.
17915192530
11101122211011112111101111111111011 < (these last two 1's come from the first infected person).
The total number of people who have bed bugs or know someone who has bedbugs is 31. We get this by multiplying the number of infected people by 5 and subtracting the number of duplicates. 5*74=31.
If two infected people's numbers are more than 4 apart there will be no over lap between the two. However, if the difference is less than that, we must subtract the number of overlaps.
I'll leave it as an exercise to the reader to prove that the total number of people who have bed bugs or know someone with bed bugs is given by (this does not include the last element of the bugArray, a couple rules must be added for that one).
$\text{total}=\displaystyle \sum_{i=0}^{\text{number of infected people1}} \left\{ \begin{array}{c}\text{numKnown}+1, & \text{bugArray[}(i+1)\text{]}\text{for bugArray[i]}>\text{numKnown}\\ \text{bugArray[}(i+1)\text{]}\text{bugArray[i]}, & \text{for bugArray[i]}<=\text{numKnown} \end{array} \right\}$
Here, numKnown means the number of people each subjects knows (in the example above, numKnown=4 and in the original problem, numKnown=500).
Hint: shift all the values in the example above 2 right so they become
17915192530
11111011222110111121111011111111110 < (these last two 1's come from the first infected person).
After using the above formula, and running many simulations, one can expect to find an answer between 145162 and 145173 infected people. The floor function in the problem causes all answers between 145150 and 145174 to be counted correct.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 

Problem Loading...
Note Loading...
Set Loading...
Let the probability of having bed bugs be $p$ . Since 1 in 5 people know someone with bed bugs (which may be themself), 4 in 5 doesn't. Assuming having bed bugs is independent between people, the probability that someone doesn't know anyone with bed bugs is simply $(1p)^{501}$ . This must be equal to $0.8$ ; by Wolfram Alpha, we obtain $p \approx 0.0004452971\ldots$ . The expected number of people with bed bugs is then $326000000 \cdot p \approx 145166.8662\ldots$ , which rounds to $\boxed{145150}$ .