<pre>
<script>
const randomNetto = length => {
let ar = [],
sum = 0;
for (let i = 1; i <= length / 2; i++) {
var n = 1,
j = length;
for (let k = i; k; k--) {
n *= j--;
n /= k;
}
sum += n;
ar.push(sum);
}
ar = ar.map(a => a / sum);
return random => {
let len = 0;
for (let k of ar) {
len++;
if (random < k) break;
}
return len
}
}
function splitSet(set) {
const random = a => Math.trunc(Math.random() * a),
sort = (a, b) => a - b;
let {
length
} = set = set.slice(0), ar = [], count = randomNetto(length), n = count(Math.random());
for (let i = 0; i < n; i++) {
let k = random(length - i);
ar.push(...set.splice(k, 1))
}
ar.sort(sort);
return ar[0] == 1 ? [ar, set] : [set, ar];
}
let v1 = 0;
let v2 = 0;
let v3 = 0;
let v4 = 0;
let v5 = 0
for (let i = 0; i < 63000; i++) {
let [s1, s2] = splitSet([1, 2, 3, 4, 5, 6, 7])
//document.write(`[[${s1}],[${s2}]], ${s1.length}, ${s2.length}<br>`)
if (s1.length == 1 && s1[0] == 1) v1++
if (s1.length == 2 && s1[0] == 1 && s1[1] == 2) v2++
if (s1.length == 3 && s1[0] == 1 && s1[1] == 2 && s1[2] == 3) v3++
if (s1.length == 4 && s1[0] == 1 && s1[1] == 2 && s1[2] == 3 && s1[3] == 4) v4++
if (s1.length == 5 && s1[0] == 1 && s1[1] == 2 && s1[2] == 3 && s1[3] == 4 && s1[4] == 5) v5++
}
document.write(`[1] - ${v1} [1,2] - ${v2} [1,2,3] - ${v3} [1,2,3,4] - ${v4} [1,2,3,4,5] - ${v5}`)
</script>
</pre>