# Probability of making a set with no data when splitting a sparse dataset

Suppose you have a $$N \times M$$ dataset with sparse data columns.
In each row there is at least one data point (i.e. at least one of the $$M$$ properties has data).
However, the number $$n$$ of data points in each column (count of data points per property) is very variable, it can vary from close to $$N$$ to almost $$0$$ (but not exactly $$0$$).

You want to randomly split the dataset (by rows) into subsets, say, $$10:90$$, or $$20:80$$, or $$20:20:20:20:20$$ (as percentages, so e.g. $$10:90$$ would be $$0.1 \cdot N$$ rows $$:$$ $$0.9 \cdot N$$ rows, or the closest integers).

The question I am trying to answer is: for a given property (column) that has $$n$$ data points in the total $$N$$ rows, what is the probability that at least one empty set (set without data) is formed, by random splitting the $$N$$ rows into subsets of specified sizes ?

I thought I had cracked it by using the hypergeometric probability density.
In a $$10:90$$ split, I had (wrongly) reasoned, I just need to know how often the smaller set is empty, so that would be the probability of picking exactly $$0.1 \cdot N$$ empty items from a pool of $$N$$ items, $$N-n$$ of which are empty.
And I thought the same would apply to multiple (non-two-fold) splits, always looking at the smaller set.

From numerical tests, it turns out I was wrong.

E.g. in R, imagining to start from a set of $$N = 10$$ records, $$2$$ of which have data:

require(combinat)

l <- permn(c(rep(0, 8), rep(1, 2)))

N_at_least_one_empty = 0

for (li in l) {
if ((sum(li[1:1]) == 0) + (sum(li[2:10]) == 0) > 0)
N_at_least_one_empty = N_at_least_one_empty + 1
}

print(paste0("
Probability that at least one set is empty in a 1:9 split = ",
N_at_least_one_empty / length(l)))
print(paste0("dhyper = ", dhyper(1, 8, 2, 1)))

# [1] "Probability that at least one set is empty in a 1:9 split = 0.8"
#[1] "dhyper = 0.8"


But already with a $20:80$ split this logic falls apart:

N_at_least_one_empty = 0

for (li in l) {
if ((sum(li[1:2]) == 0) + (sum(li[3:10]) == 0) > 0) N_at_least_one_empty = N_at_least_one_empty + 1
}

#[1] "Probability that at least one set is empty in a 2:8 split = 0.644444444444444"
#[1] "dhyper = 0.622222222222222"


I suppose this is because there are cases where the two records with data end up in the smaller set, so the larger one can be empty.

Worse, in the $$20 \times 5$$ split, it is obviously actually impossible to not have an empty set.
But the hypergeometric formula I used would not capture that.

I can imagine that one solution is to consider all the interactions.
So e.g. for the $$20:80$$ split:
$$P(at\ least\ one\ empty) = P(smaller\ empty) + P(larger\ empty) = 8/10 \cdot 7/9 + 8/10 \cdot 7/9 \cdot ... \cdot 1/3 \approx 0.6222 + 0.0222 = 0.6444$$

This one could still be written as a simple sum of hypergeometric densities.

But what about the 5-fold split of $$20%$$ each?

I tried thinking in terms of $$P(at\ least\ one\ empty) = 1 - P(all\ with\ at\ least\ one\ data\ point)$$, but that does not seem to take me closer to a solution.

Any suggestions?
Are there any known formulae/principles to tackle this case?

EDIT possible step forward after some work

I will reformulate the problem for clarity.
You have a set of $$N$$ balls, $$n$$ black (representing the presence of data), $$N-n$$ white (representing the absence of data).
You want to split them randomly into $$S \le N$$ subsets of sizes $$N_1, N_2, ..., N_S$$, s.t. $$\sum_{i=1}^S N_i = N$$, $$N_i > 0\ \forall i$$.
What is the probability $$P$$ that at least one of the $$S$$ sets only has white balls?

By examining the case $$S = 2$$:

$$P = P(set\ 1\ all\ white) \cdot P(set\ 2\ at\ least\ one\ black) + P(set\ 1\ at\ least\ one\ black) \cdot P(set\ 2\ all\ white)$$

For $$S = 3$$:

$$P = P(0,0,1) + P(0,1,0) + P(0,0,1) + P(0,1,1) + P(1,0,1) + P(1,1,0)$$

where $$P(0,0,1)$$ means "set 1 all white AND set 2 all white AND set 3 at least one black", i.e. the $$i-th$$ element in the $$P()$$ expression is $$0$$ when the $$i-th$$ set has all white balls, and $$1$$ when the $$i-th$$ set has at least one black ball.

I think the formula is solved for $$S = 2$$.
Considering that $$P(set\ 2\ at\ least\ one\ black) = 1 - P(set\ 2\ no\ black)$$ and that when set $$1$$ has all white balls, at least one black ball must definitely end up in set $$2$$, making $$P(set\ 2\ no\ black) = 0$$ and therefore $$P(set\ 2\ at\ least\ one\ black) = 1$$:

$$P_{S=2} = H(N_1, N-n, n, N_1) \cdot 1 + 1 \cdot H(N-N_1, N-n, n, N-N_1)$$

where $$H(q, m, n, k)$$ is like dhyper in R, i.e. the probability of drawing $$q$$ white balls from an urn containing $$m$$ white balls and $$n$$ black balls, by randomly picking $$k$$ of them.

For $$S >= 3$$, under the simplifying assumption that subsets can no longer be of different sizes, but $$N_i = \frac N S \ \forall i$$ (and assuming that $$N$$ is an integer multiple of $$S$$), all $$P()$$ expressions with the same combination of $$0$$'s and $$1$$'s have the same identical value, so only the number of $$0$$'s (and $$1$$'s) in each matters, and also determines how many identical $$P()$$'s are summed up:

$$P_{S\ equal\ sets} = \sum_{n_0 = 1}^{S-1} \binom S {n_0} \cdot Q(n_0, S - n_0)$$

where $$Q(a, b)$$ is a $$P()$$ expression with $$0$$ repeated $$a$$ times and $$1$$ repeated $$b$$ times.

Assuming this makes sense, the remaining question is how to calculate $$Q(a, b)$$.
Intuitively I imagine it will be some combination of $$H()$$ expressions, but I am not sure how to handle the cases where there is more than one $$1$$.

Any advice ? Am I missing anything obvious that would simplify the calculation ?

EDIT 2 applying the suggestion made by user @num_39

This consideration was correct:

$$P(at\ least\ one\ empty) = 1 - P(all\ with\ at\ least\ one\ data\ point)$$

according to @num_39's suggestion, if I am interpreting it correctly, the calculation of $$P(all\ with\ at\ least\ one\ data\ point)$$ could be done using the 'classic occupancy distribution' theory.
If $$n$$ balls are randomly distributed between $$m$$ bins, the probability that $$k$$ bins contain at least one ball is:

$$Occ(k|n,m) = \frac {1} {m^n} \cdot \prod_{i=0}^{k-1} {(m-i)} \cdot \sum_{i=0}^{k} {\frac {(-1)^{k-i} \cdot i^n} {(k-i)! \cdot i!}}$$

For the calculation of this probability in my example, I ignore the white balls; this leaves $$n$$ black balls to distribute randomly among $$m=S$$ bins; we want $$k=S$$.

$$P(all\ with\ at\ least\ one\ data\ point) = Occ(S|n,S) = \frac {S!} {S^n} \cdot \sum_{i=0}^{S} {\frac {(-1)^{S-i} \cdot i^n} {(S-i)! \cdot i!}}$$

Does it work?
For instance, for my $$S=2$$ case, assuming $$N_1 = N_2 = N/2$$:

• using my own formula:

$$P_{S=2\ equal\ sets} = 2 \cdot H(N/2, N-n, n, N/2) = 2 \cdot \frac {(N-n)! \cdot (N/2)!} {N! \cdot (N/2-n)!}$$

• using the new formula:

$$P_{S=2\ equal\ sets} = 1 - \frac {2!} {2^n} \cdot \sum_{i=0}^{2} {\frac {(-1)^{2-i} \cdot i^n} {(S-i)! \cdot i!}} = 1 - \frac {2!} {2^n} \cdot (2^{n-1}-1) = 2^{1-n}$$

This does not seem to match (?).

EDIT 3 R simulation as per @whuber's suggestion

N <- 10 # total size of set
n <- 2 # number of black balls (presence of data) in set
m <- 2 # number of subsets to make (must be a divisor of N)

original_set <- c(rep(0, N - n), rep(1, n))

subset_size = N / m
if (floor(subset_size) != subset_size) stop("N must be an integer multiple of m")

i = seq(from = 1, N, by = subset_size)

N_cases_with_at_least_one_empty_set = 0

for (loop in 1:100000) {
random_sel <- sample(original_set, size = N, replace = FALSE)
for (ii in i) {
if (sum(random_sel[ii:(ii + subset_size - 1)]) == 0) {
N_cases_with_at_least_one_empty_set = N_cases_with_at_least_one_empty_set + 1
break
}
}
}

P1 = N_cases_with_at_least_one_empty_set / 100000
print(P1)


Result:

#[1] 0.44409
# which is close to the theoretical 4/9


EDIT 4 more work towards a possible general solution, taking up whuber's and num_39's suggestions

Suppose $$N=6, n=3$$, i.e. a data column of 6 records, 3 of which have data.

This has $$N! = 6! = 720$$ permutations, but if all records with data ('black balls') are considered equivalent, and all records without data ('white balls') are considered equivalent, the number of distinct sequences you can make from this configuration is $$\binom N n = \binom 6 3 = \frac {6!} {3!3!} = \frac {720} {36} = 20$$.

Here they are enumerated out:

If you want to split data into $$m = 3$$ bins:

there are $$8/20 = 40\%$$ of them where all (3) bins have at least 1 black ball.
Consequently, there are $$60\%$$ of them where at least one bin has all white balls (no data as per initial problem).
By running the above simulation, this proportion is confirmed.
This seems to support the idea that going from permutations to sequences is OK.

How to justify this result of '8' theoretically?
One could say: you have 3 black balls, you want to put them into 3 bins with 2 positions each, so you have 2 choices per bin and 3 bins, which gives $$2^3 = 8$$ cases. (Not sure how general this is though).

However, if you want to split data into $$m = 2$$ bins:

there are $$18/20 = 90\%$$ cases where all (2) bins have at least 1 black ball.
Consequently, there are $$10\%$$ of them where at least one bin has all white balls (no data as per initial problem).
By running the above simulation, this proportion is confirmed.

How does this '18' come about though?

I think whuber's suggestion is a start: we want to know how many distinct partitions of the 3 black balls into exactly 2 bins can be made.
That is $$3 = 1+2 = 2+1$$.
But then we also need to consider that each bin has 3 positions in which the black balls can go.
A bin with 3 positions and 1 black ball has $$\binom 3 1 = 3$$ possible configurations.
A bin with 3 positions and 2 black balls has $$\binom 3 2 = 3$$ possible configurations.
Each bin is filled independently, so the number of configurations need to be multiplied; and both symmetrical cases $$1+2$$ and $$2+1$$ need to be considered, so in total:

$$2 \cdot 3 \cdot 3 = 18$$

Assuming this is theoretically correct, the hard part (for me at least) is to get the list of all partitions of a number $$n$$ into $$m=k$$ bins.
Then applying the above calculations is relatively easy:

$$\sum_{partitions} {\prod_{summands} {\binom {N/m} {s} } }$$

This could also become very computationally demanding when the 'real' numbers involved in this kind of problems are used ($$N$$ could be in the 100 K's, $$n$$ from 100 to 100 K's).

To obviate that, as suggested by num_39, the occupancy theory and its R functions might be used.
But then how? And does it really answer the question of what proportion of sequences has all bins occupied?

• The probability depends (heavily) on the patterns of missingness among the columns. If this is a theoretical problem, consider modeling the columns as independent binary vectors. But if it's a practical one, you can solve it quickly with a short simulation: do the splitting a few thousand times and summarize the results.
– whuber
Apr 9 at 13:16
• Thanks @whuber ; maybe I introduced some confusion by mentioning the $N \times M$ dataset. I am OK thinking about this problem as if there were only 1 sparse column ($M = 1$). But had I presented it like that people might then say 'just do a dropna and you'll have no missing data'. The core problem is what I put in bold in the post. The randomness of splitting should make it independent from the pattern of empty/data cells (right?). Theoretical or practical: a bit of both. We do the random splitting, and we want to estimate the risk of having at least one empty set in the 'most empty' column. Apr 9 at 15:31
• See the second answer to this question for an answer to your simplified question about one sparse column. This is just 1 - the probability that all bins are occupied. stats.stackexchange.com/questions/572608/… Apr 9 at 22:20
• @whuber : you seem to have read my mind. I wrote out all the possible sequences of black and white balls from a set of 6 balls of which $n = 2$ or $n = 3$ were black, which are of course $\binom N n$. After dividing the sequences up into $m = 2$ or $m = 3$ bins of size $N/m$, I considered the problem of how many sequences had all bins with at least one black ball in them. That question is the same as asking in how many ways you can distribute $n$ balls in $k$ bins so that no bin is empty, which I believe is close to your point about partitions. Making us sweat for it though, eh? :) Apr 10 at 19:46
• Here's another hint: you don't necessarily need a full solution. You only need to compare the number of ways of putting at least one ball into each bin compared to the number of ways of distributing the balls among the bins. The former is the number of ways of first manually placing one ball in each bin and then randomly distributing the remaining balls in the bins--which is the same question but with slightly different parameters.
– whuber
Apr 10 at 19:50

In the comments edits the OP poses a simpler question: Considering only a single sparse vector and given that the data will be split into subsets of equal size, what is the probability that one subset will contain no data. For simplicity, I will subsequently refer to this probability as $$\mathbb{P}_{wo}$$.

Here make several contributions toward a solution.

• First, I show that the probability from the classical occupancy distribution, $$\mathbb{P}_{wr}$$, gives an upper bound for $$\mathbb{P}_{wo}$$.
• Second, I show that for $$\mathbb{P}_{wo} \to \mathbb{P}_{wr}$$ as the data becomes more and more sparse.
• Third, I provide a solution for the case where the number of data points equal the number of splits.
• Fourth, I provide a solution for the case where the number of data points equal the number of splits plus one.

## 1. Occupancy distribution as an upper bound

In the classical occupancy problem, we're interested in the number of empty bins after we randomly distribute $$n$$ balls across $$m$$ bins. This involves sampling with replacement as each ball is independently assigned to a bin without respect to prior assignments. Let $$k$$ represent the number of occupied bins. The occupancy distribution gives us the following for the number of occupied bins.

$$Occ(k|n,m) = \frac {1} {m^n} \cdot \prod_{i=0}^{k-1} {(m-i)} \cdot \sum_{i=0}^{k} {\frac {(-1)^{k-i} \cdot i^n} {(k-i)! \cdot i!}}$$

We're interested in finding the probability for the case where $$m = k$$. Substituting $$m$$ for $$k$$ and my notation from above for this specific probability, this simplifies the above expression to

\begin{aligned} \mathbb{P}_{wo} &= \frac {1} {m^n} \cdot \prod_{i=0}^{m-1} {(m-i)} \cdot \sum_{i=0}^{m} {\frac {(-1)^{m-i} \cdot i^n} {(m-i)! \cdot i!}} \\ &= \frac {m!} {m^n} \cdot \sum_{i=0}^{m} {\frac {(-1)^{m-i} \cdot i^n} {(m-i)! \cdot i!}} \end{aligned}

Since we're interested in the probability of at least one empty bin, we want $$1 - Occ(m|n,m)$$.

We can calculate this in R as follows. Take the case of 5 balls distributed across 4 bins.

n <- 5
m <- 4
x <- 0

for(i in 1:m) {
x <- x + ( (-1)^(m - i) * i^n ) / ( factorial(m - i)  * factorial(i) )
}

1 - factorial(m) / m^n * x


The probability that at least one bin is empty is ~0.77. This code is only feasible for small numbers. For more difficult computations, you can use the occupancy package in R. I think this also covers cases where bins are of varying sizes.

n <- 5 # Number of balls
m <- 4  # Number of bins
k <- m # Number of occupied bins

1 - occupancy::docc(k, n, m)


This also returns ~ 0.77.

We can also devise a simple simulation. Notice that taking a sample of $$n$$ from the vector 'c(1, 2, 3, 4)' and then calculating the unique numbers drawn is equivalent to placing $$n$$ balls randomly into 4 bins.

set.seed(300)
x <- sapply(1:10000, function(i) length( unique (sample(1:4, 5, replace = TRUE))))
mean(x < 4)


This returns ~0.77 which is approximately correct.

Informally, we know that $$\mathbb{P}_{wr} > \mathbb{P}_{wo}$$ because the first ball will fall in an unoccupied bin. Under the classical occupancy problem, the second ball is just as likely to fall into the occupied bin as to fall into an unoccupied bin. These probabilities are fixed. However, for our case which involves sampling without replacement, the second ball is less likely to fall into the occupied bin, $$\frac{m/N - 1}{N -1}$$, than an unoccupied bin, $$\frac{m/n}{N-1}$$ and so forth.

## Occupancy distribution as a sparse approximation

Again, informally, if we let $$N$$, the number of rows increase and hold $$n$$, the number of data points and $$m$$, the number of bins constant, then asymptotically we approximate sampling without replacement such that $$\mathbb{P}_{wo} \to \mathbb{P}_{wr}$$.

Below I provide a simulation to suggest when the occupancy probability might be a good approximation for the probability in question.

Now consider the actual problem in question which involves sampling without replacement. Using the below code with again 4 bins, 5 red balls ($$n$$ from above), and 15 white balls, returns a bin without any red balls ~0.68, this is much lower than the numbers provided by the occupancy distribution. However, holding the number of bins and red balls fixed and increasing the $$N$$ to 100 (the number of white balls to 95) returns a value of ~0.75.

N <- 100
red <- 20
wh <- N - red
k <- 5
n_j <- N / 10
x <- c(rep(1, red), rep(0, wh))

set.seed(48)

z <- sapply(1:10000, function(i) {
x <- sample(x, length(x))
a <- matrix(x, nrow = k, ncol = n_j)
sum( rowSums(a) == 0 ) }
)

mean(z > 0)


Increasing $$N$$ to 1000, gets us to ~0.76.

## A solution for n = m

For the special case where the number of red balls, $$n$$, equals the number of bins, $$m$$. A solution is given by

$$\mathbb{P}_{wo_{n = m}} = 1 - \prod^{m - 1}_{i = 1} (1 - i \cdot \left( \frac{N/m - 1}{N -i} \right))$$

This is intuitive because we need each bin to fall into an unoccupied bin and these probabilities can be easily computed, i.e. the probability that the first ball falls into an unoccupied bin is 1, the probability that the second ball falls into an unoccupied bin is 1 minus the probability that the ball falls into the already occupied bin and so forth.

For the case where $$n = m = 4$$ and $$N = 20$$, we compute this probability in R.

n <- 4
m <- n
N <- 20
x <- 1
n_j <- N / m

for(i in 1:(m - 1) ) {

x <- x * ( 1 - i * ( (n_j - 1) / (N - i ) ) )

}

1 - x


This gives us ~0.871

A simulation confirms this result.

N <- 20
red <- 4
wh <- N - red
m <- 4
n_j <- N / m
x <- c(rep(1, red), rep(0, wh))

set.seed(48)

z <- sapply(1:1000000, function(i) {
x <- sample(x, length(x))
a <- matrix(x, nrow = m, ncol = n_j)
sum( rowSums(a) == 0 ) }
)

mean(z > 0)


This gives us ~0.871.

## A solution for n = m + 1

We can extend the solution above to the case where $$n = m + 1$$. This is just $$\mathbb{P}_{wo_{n = m}}$$ plus the probability that the first $$m$$ balls fall into exactly $$m - 1$$ bins times the probability that the last ball falls into the single unoccupied bin. If I haven't made any errors in my calculations and simulations, this is given by

$$\mathbb{P}_{wo_{n = m + 1}} = \mathbb{P}_{wo_{n = m}} + \frac{N/m}{N - m} \cdot \sum_{j = 1}^{m - 1} \left( \frac{j(n-1)}{N - j} \cdot a \cdot b \right)$$

where

$$a = \begin{cases} \prod_{i = 1}^{j - 1} \left( 1 - \frac{i(n - 1)}{N - i} \right) & \text{if } j - 1 > 0 \\ 1 & \text{otherwise} \end{cases}$$ and

$$b = \begin{cases} \prod_{i = j + 1}^{m - 1} \left( 1 - \frac{(i-1)(n - 1) - 1}{N - i} \right) & \text{if } j + 1 \le 0 \\ 1 & \text{otherwise} \end{cases}$$

Obviously the terms in the summation are what's difficult--and perhaps I should have written this as a matrix--but as far as I can tell this check out with the simulations.

For the case of $$N = 40$$ and $$n = 5$$, the probability that after the first $$5$$ balls exactly one bins is empty is ~0.436 by the following calculation

m <- 5
N <- 40
n <- N / m

y <- 0

for(j in 1:(m - 1)) {

x <- j * (n - 1) / (N - j)

if(j - 1 > 0) { #Value before doubling
for(i in 1:(j - 1)) {
a <- (1 - i * (n - 1) / (N - i))
x <- x * a
}
}

if(j + 1 <= m -1 ) {
for(i in (j + 1):(m - 1)) { #Value after doubling
c <- (1 - ((i - 1) * (n - 1) - 1 ) / (N - i) )
x <- x * c
}
}

y <- y + x
}

y


Now we check this with a simulation.

N <- 40
red <- 5
wh <- N - red
k <- 5
n_j <- N / k
x <- c(rep(1, red), rep(0, wh))

set.seed(48)

z <- sapply(1:100000, function(i) {
x <- sample(x, length(x))
a <- matrix(x, nrow = k, ncol = n_j)
sum( rowSums(a) == 0 ) }
)

mean(z == 1)


And here we get ~0.435

This could be extended further but the approach is tedious. I imagine there's a much better way to work this out and a clearer way to present it--perhaps using matrix notation.

• Thanks, but I am struggling to see how this can possibly work. As I commented above, $N$ must count for something in this problem. And the formula does not match for $S=2$, as I showed, neither formally nor numerically. My formula gives $P = 4/9$, the one based on the occupancy theory gives $P = 1/2$. Apr 10 at 11:32
• Also I think you put a $2$ where $m$ was meant in your R code. Apr 10 at 11:33
• And $4/9$ is the correct result from an R simulation like the one in my OP, where I counted how many permutations have the first 5 or the last 5 elements equal to 0 when splitting a set of 10 records, 2 of which have data. Apr 10 at 11:40
• Maybe I have misunderstood your question. What would $N$ represent in the classical occupancy problem? For the case of data splitting, if we're splitting into equal sizes, the number of rows we're splitting doesn't matter, only the number of row which for a particular vector contain data. This is $n$ in the classical occupancy problem. I will have to look back at your simulation to better understand what you're trying to answer. Apr 10 at 11:56
• Yes, probably, because just now I made a simulation like whuber suggested, and I can confirm that $4/9$ is the answer, whereas your R method gives exactly $1/2=0.5$. Apr 10 at 12:04

The problem can be described with restricted composition with and without zeros. Here you are randomly placing $$n$$ non-zero records into $$m$$ bins of sizes $$S=s_1,s_2,...s_k$$, where the total number of records is $$\sum{S}=N$$.

The following procedure will get the desired probability:

1. Enumerate all restricted compositions without zeros (each forms a multiset)
2. Calculate the number of ways to form each multiset and sum the result
3. Repeat steps 1-2 with zeros allowed

The probability that all subsets have at least one data point is the result of step 2 divided by the result of step 3.

This is implemented in the R function prob0 below. The function is certainly not optimized, and I would recommend modifying it to work in log-space for larger problems to avoid overflow due to combinatorial explosion.

prob0 <- function(n, s) {
if (n < length(s)) {
1
} else {
f <- function(n, s, m, cs, k, nz) {
if (m == 1) {
k*choose(s, n)
} else {
sum(
vapply(max(n - s[m], nz*(m - 1)):min(n - nz, cs[m]),
\(i) f(i, s[-m], m - 1, cs[-m], k*choose(s[m], n - i), nz), 0)
)
}
}

m <- length(s)
cs <- c(0, cumsum(s[-m]))
1 - f(n, s, m, cs, 1, 1)/f(n, s, m, cs, 1, 0)
}
}


Example usage:

prob0(2, c(2, 8)) # 2 observations in 10 rows split 20:80
#> [1] 0.6444444
prob0(2, rep(2, 5)) # 2 observations in 10 rows split 5 ways
#> [1] 1
prob0(2, c(5, 5)) # 2 observations in 10 rows split 2 ways
#> [1] 0.4444444
prob0(3, rep(2, 3)) # 3 observations in 6 rows split 3 ways
#> [1] 0.6
prob0(3, c(3, 3)) # 3 observations in 6 rows split 2 ways
#> [1] 0.1
prob0(6, 1:4) # 6 observations in 10 rows split 10:20:30:40
#> [1] 0.5333333

• Thanks, interesting approach. In the meantime the question was answered in math SE, see my last comment under my OP. Apr 16 at 9:56