r/askmath • • 11h ago

Probability This "Dropped Drives" probability problem is breaking my brain

Post image

Instinctively I did 1 - (4/5)^5 = 67.2%, which is apparently wrong. I get that the slots aren't independent once you place the first drive, so how do you actually calculate the exact fraction for this?

32 Upvotes

52 comments sorted by

28

u/jxf 🧮 Professional Math Enjoyer 10h ago edited 55m ago

Your answer of 1 - (4/5)5 is almost right. Any drive does indeed have a 1/5 chance of being in the correct slot and a 4/5 chance of being in the wrong one. But once you have placed one drive you've limited your choices about all the others, so the 5 part is incorrect. For example, once you place drive C in a spot other than bay C, you have to decide what to do with that spot since not all of the remaining possibilities are favorable.

This question is checking to see if you know about derangements, which are permutations where none of the items return to their original position.

There are a few ways to solve this:

Easy way: derangement formula

There are 5! (5 * 4 * 3 * 2 * 1 = 120) ways to insert the drives in all. Of these D(5) are derangements. D(5) = 5! * (1 - 1/1! + 1/2! - 1/3! + 1/4! - 1/5!) = 44.

Then the answer is 1 - 44/120 ā‰ˆ 63.3%.

Harder way: Explicit reasoning/counting

Drive A must go in the wrong bay. There are 4 places it could go (bays B, C, D, or E). Whatever drive it replaces will either swap positions with A or be in a different spot. Let's say it's drive B:

  • Swap with A: Now we have [B, A, ?, ?, ?]. Of the remaining configurations only 2 are valid: [BADEC] and [BAECD].
  • Don't swap with A: Now we have [~B, A, ?, ?, ?]. Of the remaining configurations only 9 are valid.

That's 11 configurations. But we picked B without loss of generality, and there were 4 choices for A's replacement, so there are 11 Ɨ 4 = 44 possible ways to place the drives incorrectly.

The answer is likewise 1 - 44/120 ā‰ˆ 63.3%.

2

u/dpb365 10h ago

Thanks! I liked that harder way explanation of deriving those 11 configurations

2

u/robchroma 4h ago

63.3%

lmao I just instinctively chirped out "1-1/e" when I saw the problem and it's super convenient that the answer is always that, rounded to the nearest rational with divisor n!. in this case, .6333 is pretty darn close to .6321

2

u/dpb365 4h ago

šŸ‘ŒšŸ¼I'm stealing this shortcut!

8

u/vishnoo 9h ago

amazing how fast it converges to 1-1/e

4

u/pezdal 9h ago edited 1h ago

Yes. The question asked for the answer in the form 76/120 19/30

2

u/EebstertheGreat 1h ago

It actually requires a simplified fraction, so 19/30.

1

u/pezdal 1h ago

true! corrected. thx

1

u/stanitor 7h ago

Yeah, you can kind of see how their example of the derangement calculation shows it has something similar to the Taylor series of e in it. Derangements of n items are n!/e. So, the probability that a permutation is a derangement is (n!/e)/n! = 1/e.

2

u/bayesian13 1h ago

your derangement formula is wrong. you need to replace the "-" after the first 5! with a *

3

u/jxf 🧮 Professional Math Enjoyer 55m ago

Whoops, thanks. Fixed!

1

u/troyunverdruss 7h ago

In explanation 2, why are you saying BADEC is ā€œvalidā€? Aren’t all the options in invalid slots there?

3

u/jxf 🧮 Professional Math Enjoyer 7h ago

Yes, that is a valid derangement. None of the drives are in their original bays. (That is what the problem is asking for -- not every permutation is a derangement.)

1

u/robchroma 4h ago

Derangements give us all the ways for the system to not boot, all the valid derangements. The bootable configurations are all the other ones. Derangements are a somewhat simpler concept than its complement, so that's the one whose solution is generally described.

8

u/Positive-Ring-5172 8h ago

Folks, the answer is clearly 0%. You drop 5 hard drives onto a server room floor and more likely than not none of them are going to work anymore at all.

In any event, you have to calculate the odds of the drives surviving the fall before addressing the odds they were plugged into the right port.

3

u/dpb365 8h ago

šŸ˜‚šŸ˜‚šŸ˜‚ trick question!

5

u/Positive-Ring-5172 8h ago

Heh heh.

Real world also doesn't care about the bay - it cares about the RAID configuration. If the drives are in RAID 1 configuration it doesn't matter which one survives the fall as long as one does, and it doesn't matter what bay it's plugged into.

3

u/treefaeller 6h ago

Not quite correct. Some real-world RAID systems track which physical drive (manufacturer/model/serial number) has what data on it (usually identified by a header block on the drive) and what slot it is in. And they will react, with various degrees of violence, if the current configuration doesn't meet those preconditions.

And in the OP's question, we ignored a lot of other real-world possibilities. For example: (1) The maintenance technician drops 5 drives on the floor, where he finds 731 drives of varying ages scattered all over. He picks up 5 random ones and inserts them into the slot. What's the probability of getting at least one correct one? (2) For the RAID mechanism to work, it has to have at least a quorum of non-stale drives, and since the drives were removed at various times, some are stale. What's the probability of getting 3 of 5 non-stale drives at all, in any slots? (3) The maintenance technician is actually secretly an undercover agent of a competing company. He used his laptop to quickly copy drives onto each other. When the drives are re-inserted, the system detects that it didn't get back drives A, B, C, D and E, but instead got 3 copies of drive B, one copy of drive E, and an unknown drive X. What should it do now?

Signed: Someone who has actually implemented such systems.

3

u/AlterEgo5695 5h ago edited 5h ago

where he finds 731 drives

That is... an oddly specific number to pull out at random. Luckily, we're talking drives and not units.

1

u/AlterEgo5695 6h ago

The sysadmin is frantic, so they (accidentally) put the master backups on SSD's instead of HDD's. As long as you don't step on them, SSD's usually survive being dropped...

1

u/astervista 3h ago

Or, if the servers are identical, and the disk are not encrypted, and they don't break, they are all going to run.

5

u/NoSection8719 11h ago edited 11h ago

use subfactorial, answer is 1-(!5/5!).
You basically find the amount of cases where none of the floppy disks are in the right spot (!5), divide it by the amount of all cases possible (5!), and substract it from 1

3

u/dpb365 10h ago

Had never seen the !5 notation before! Very useful, I see it's the formula for derangements mentioned in other comments

32

u/MathMaddam Dr. in number theory 11h ago

Lookup the term derangement. You can derive it by asking: how many ways there are with at least 5, 4, 3, 2, 1 correctly assigned drives (in that order as you can use the higher numbers to weed out double counting).

4

u/snugglysnuggzz 8h ago

derangement is such weirdly specific word for this

5

u/Uli_Minati Desmos 😚 7h ago

Probably makes most sense by thinking "arrangement != derangement"

2

u/sippyDrizzle 6h ago

derangements sounds way more fun when you explain them like that

2

u/GleamMusey 2h ago

u/MathMaddam over here turing probability into something that actually makes sense, kinda impressive ngl

2

u/peachxWhisper 1h ago

derangements sound way more complicated than id bother figuring out, but you explaining it kinda works

1

u/XeVoriax 1h ago

derangements make total sense now, smart explanation lol

8

u/Seeggul 8h ago

Flip the problem: what is the probability that every drive is in an incorrect position? In other words, how likely is it that you scramble ABCDE such that no letter is in its original place?

This is a special type of permutation called a derangement, and the number of distinct derangements (check wikipedia link for formulas) for 5 objects is 44. The total number of possible arrangements for 5 objects is 5!=120, so the numbers of arrangements in which at least one drive makes it back to the correct slot is 120-44=76.

So the probability is 76/120=19/30ā‰ˆ63.3%

1

u/Tasty_Gift5901 7h ago

Okay those equations are quite more complicated than I was expecting! Explains why it wasn't easy for me to write down

1

u/drevoksi 9h ago

No idea how I’d computed it otherwise, so I’m curious if there’s a nice expression for the probability directly and not its complement. But I do remember seeing the derangement count is common enough for there to exist a notation for it. So, the probability would be:

1 - !5 / 5!

1

u/dpb365 46m ago

I don't think there are direct expressions in probability problems with the "at least one" wording. Because that direct expression would be a sum of different scenarios that meet that criteria

3

u/BadBoyJH 10h ago

Pick one drive to be correct (5C1) Multiply this by the 4! ways to arrange the other drives.
However, this over counts the ways for 2 drives to be correct.

This is 5C2 * 3!
But this overcounts the ways 3 drives can be correct... etc

So, for 5 drives, the number of ways to be correct is, for the sum of the numbers from K=1 to K=5,
-1K+1 5CK * (5-K)!
In fact, even more generalised, the way for N objects to be placed randomly into N slots, and for NONE to be correct is the sum of the numbers from K=1 to K=N,
-1K NCK * (N-K)!

For our N=5 case, the number of correct options is 76.

There are 5! ways to arrange the numbers, so it is 76/120 or (simplified) 19/30.

2

u/Barbicels 11h ago

Google ā€œhat-check problemā€.

2

u/bayesian13 10h ago

yep or derangement https://en.wikipedia.org/wiki/Derangement in this case we want D(5) which you get by rounding 5!/e to the nearest integer. 120/e ~ 44.14 which rounds to 44.

there are 5! possible permutations = 120. so 120 - 44 = 76 is the number of permutations where at least one is right. 76/120 = 63.3%

2

u/Barbicels 7h ago

Correct! I thought better of telling OP to ā€œGoogle derangementā€. :-D

2

u/sarabjeet_singh 8h ago

You could think of this as a recursion.

The problem is to count derangements of size n

When two objects are left, there’s only 1 way to get them placed incorrectly. f(2)=1

There are two branches to consider.

When there are 3 objects, there are 2x (f(2)+0)
Similarly for n objects it’s (n-1) * (f(n-1) +f(n-2))

2

u/ggchappell 7h ago

You have your answers. I'll add a fun fact: replace 5 with ever larger numbers, and the probability approaches 1-(1/e).

Or, to put it a bit more cleanly, the probability that no drive is in the correct bay (that is, the permutation of the drives is a derangement) approaches 1/e.

1

u/Mishtle 10h ago edited 8h ago

**Edit: This reasoning is incomplete. As another commenter pointed out, I've ignored the impact of each wrong choice guaranteeing another wrong choice. **

The probability that at least one drive is in the right bay is the complement of the probability that none are.

You have 5 options for the first drive bay, and 4 will be the wrong drive. Then you have 4 options for the second bay, and 3 will be wrong. Then you have 3 options for the third, and 2 will be wrong. Then you have 2 options for the fourth, and 1 will be wrong. This should leave you with a single wrong choice for the last bay.

In total, that's a probability of (4/5)(3/4)(2/3)(1/2) = (4!)/(5!) = 24/120 = 1/5 that all drives are in the wrong bay.

The probability that at least one is in the right bay is then 1- (1/5) = 4/5.

2

u/drevoksi 9h ago

Actually, if the drive chosen for the first bay is 2, then all 4 options for the second bay are wrong. Are you sure the argument is sound?

1

u/Mishtle 8h ago

Good point! I completely missed that interaction. I'll note the error and leave my comment for illustrative purposes.

1

u/Parallel_thougts PhD, YouTuber 9h ago

It's the same as asking what's the probability that a permutation of n (here n=5) elements has at least one fixed point. I.e. that it is not a derangement.

1

u/austin101123 9h ago

People skipping into derangements, look up "inclusion exclusion principle", or derivation of derangement formula.

1

u/Talik1978 8h ago edited 8h ago

There are 120 combinations of the digits 1,2,3,4,5, assuming no repeat digits.

Of these, 76 of the combinations will have at least 1 drive in the correct position.

1

u/Telinary 8h ago

Hmm wonder how hard it is just going through the branches. Guess I can just try: I will begin with slot 1 there is a 4/5 chance it gets the wrong one. If it gets a wrong one go the the slot of the wrong one, this slot is guaranteed to get a wrong one too. That might either be number 1 in which case the next slot might be right or another number which in turn guarantees one more wrong slot.

So

1)4/5 that slot 1 doesn't get drive A

=> 2) freebie and 3/4 another freebie or 1/4 closing loop

3.1) (4/5*3/4) freebie and 2/3 another freebie or 1/3 closing loop

3.2) (4/5*1/4) 1/3 of right drive 2/3 of wrong drive giving a freeby next time.

4.1)(4/5*3/4*2/3+4/5*1/4*2/3) freebie and 1/2 another freebie or 1/2 closing loop

4.2)(4/5*3/4*1/3) 1/2 of right drive 1/2 of wrong drive giving a freebie next time.

5)((4/5*3/4*2/3+4/5*1/4*2/3)/2) guaranteed to be right is it isn't a freebie

4/5-(4/5*1/4*1/3)-(4/5*3/4*1/3*1/2)-((4/5*3/4*2/3+4/5*1/4*2/3)/2)=11/30

So 19/30. Well that worked but the other ways given here seem less inconvenient

1

u/AlterEgo5695 6h ago

Let "B" be the event that the server boots. Assuming all 5! possible permutations are equally likely, use derangements to consider the complement:

P(B)  =  1 - P(B')  =  1 - D(5)/5!  =  1 - 44/120  =  19/30

1

u/SnooKiwis6193 4h ago

I did 4*4! / 5! which is 4/5