% corroborated in matlab
clear; clc;
n=100000;
POS=sort(rand(20,n));
DIST=[repmat(realmax,2,n); POS(2:end,:)-POS(1:end-1,:); repmat(realmax,2,n)];
notCrowedAt=(DIST(1:end-3,:)<=DIST(2:end-2,:))&(DIST(3:end-1,:)>=DIST(4:end,:));
mean(sum(notCrowedAt)) % result ~ 5