Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,13 @@
program combin
tempfile cp
tempvar k
gen `k'=1
quietly save "`cp'"
rename `1' `1'1
forv i=2/`2' {
joinby `k' using "`cp'"
rename `1' `1'`i'
quietly drop if `1'`i'<=`1'`=`i'-1'
}
sort `1'*
end

View file

@ -0,0 +1,20 @@
. set obs 5
. gen a=_n
. combin a 3
. list
+--------------+
| a1 a2 a3 |
|--------------|
1. | 1 2 3 |
2. | 1 2 4 |
3. | 1 2 5 |
4. | 1 3 4 |
5. | 1 3 5 |
|--------------|
6. | 1 4 5 |
7. | 2 3 4 |
8. | 2 3 5 |
9. | 2 4 5 |
10. | 3 4 5 |
+--------------+

View file

@ -0,0 +1,14 @@
function combinations(n,k) {
a = J(comb(n,k),k,.)
u = 1..k
for (i=1; 1; i++) {
a[i,.] = u
for (j=k; j>0; j--) {
if (u[j]-j<n-k) break
}
if (j<1) return(a)
u[j..k] = u[j]+1..u[j]+1+k-j
}
}
combinations(5,3)