Last active
October 16, 2022 06:43
-
-
Save galenseilis/0324f50edbc096f0cb84430acdee666a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os.path as path | |
| from tempfile import mkdtemp | |
| import numpy as np | |
| m = 10**6 | |
| n = 10**3 | |
| filename = path.join(mkdtemp(), 'X.dat') | |
| X = np.memmap(filename, dtype='float32', mode='w+', shape=(m, n)) | |
| for k in range(n): | |
| print(k) | |
| X[:,k] = np.random.normal(size=m) | |
| beta = np.random.normal(size=n) | |
| y = np.sum(beta * X, axis=1) | |
| beta_hat = np.matmul(np.linalg.pinv(np.matmul(X.T, X)), X.T) @ y | |
| print(np.all(np.isfinite(beta_hat))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment