Created
April 27, 2020 08:35
-
-
Save NISH1001/7c201a1c6e7369af20532ccc1b9f2a0b to your computer and use it in GitHub Desktop.
generate random numbers where column sums upto something
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
#!/usr/bin/env python3 | |
import numpy as np | |
def main(): | |
ncols = 3 | |
nrows = 100 | |
arr = np.random.random((nrows, ncols)) | |
arr = arr / arr.sum(axis=0, keepdims=1) * 100 | |
print(arr.shape) | |
print(arr.sum(axis=0)) | |
np.savetxt("rand.csv", arr, delimiter=",") | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment