Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- >>> import numpy as np
- >>> a = np.random.random(5) # n values
- >>> print(a)
- [ 0.884703 0.78476467 0.26084923 0.82228242 0.48263909]
- >>> b = np.random.random(8) # m values
- >>> print(b)
- [ 0.53982228 0.59494659 0.92725768 0.03275801 0.39763316 0.72638816
- 0.37634726 0.85483384]
- >>> matrix = a[:,None] * b[None,:] # n by m matrix
- >>> print(matrix)
- [[ 0.47758239 0.52635103 0.82034765 0.02898111 0.35178725 0.64263778
- 0.33295555 0.75627406]
- [ 0.42363345 0.46689307 0.72767907 0.02570733 0.31204846 0.57004376
- 0.29534404 0.6708434 ]
- [ 0.14081223 0.15519136 0.24187445 0.0085449 0.10372231 0.18947779
- 0.0981699 0.22298275]
- [ 0.44388637 0.48921412 0.76246768 0.02693634 0.32696676 0.59729621
- 0.30946374 0.70291484]
- [ 0.26053933 0.28714448 0.4475308 0.0158103 0.19191331 0.35058332
- 0.1816399 0.41257622]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement