TITLE: If we randomly select 25 integers between 1 and 100, how many consecutive integers should we expect?
QUESTION [65 upvotes]: Question: Suppose we have one hundred seats, numbered 1 through 100. We randomly select 25 of these seats. What is the expected number of selected pairs of seats that are consecutive? (To clarify: we would count two consecutive selected seats as a single pair.)
For example, if the selected seats are all consecutive (eg 1-25), then we have 24 consecutive pairs (eg 1&2, 2&3, 3&4, ..., 24&25). The probability of this happening is 75/($_{100}C_{25}$). So this contributes $24\cdot 75/(_{100}C_{25}$) to the expected number of consecutive pairs. 
Motivation: I teach. Near the end of an exam, when most of the students have left, I notice that there are still many pairs of students next to each other. I want to know if the number that remain should be expected or not.

REPLY [12 votes]: Henning Malcolm has already answered the question about the expected value. But that says very little about how likely or unlikely it would be to get deviations from the expected value - what if you observed there were 20 pairs out of 25 students left, could that happen by chance or is there some other factor at work? To answer questions like this one would need more details about the distribution, like the variance. Unfortunately, the analytic formula for the distribution (if there is one) is likely to be very complicated. So, from a practical perspective it might be interesting to investigate things numerically. That is the purpose of this post.
Here's a histogram of the number of pairs, generated numerically from 10000 trials.

You can look at this and draw your own conclusions. I would conclude the following:

anywhere from 4 to 8 pairs would be totally reasonable, 
0 pairs or 13+ pairs would be very strong evidence of there being another factor
anything inbetween would be unusual, but possible

Here's the Matlab code used to generate it:
n=100; 
k=25; 

num_trials = 1e4;
num_pairs = zeros(num_trials,1);
for ii=1:num_trials
    disp(ii)
    filled_seats = sort(randperm(n,k));
    gaps = filled_seats(2:end) - filled_seats(1:end-1);
    num_pairs(ii) = length(find(gaps == 1));
end

histogram(num_pairs)
title(sprintf('histogram of seating pairs (out of %d trials)',num_trials))