dtype keyword for np.random.randint and np.random.rand
See original GitHub issueAs brought up at the mailinglist, this code ates up much memory:
spectrumArray = np.random.randint(0,255, (2**20,2**12)).astype(np.uint8)
It has also crossed my mind that np.random.randint and np.random.rand could use an extra ‘dtype’ keyword. It didn’t look easy to implement though.
See this thread on the mailinglist: [Numpy-discussion] array of random numbers fails to construct
Issue Analytics
- State:
- Created 8 years ago
- Comments:29 (21 by maintainers)
Top Results From Across the Web
numpy.random.randint — NumPy v1.24 Manual
Return random integers from the “discrete uniform” distribution of the specified dtype in the “half-open” interval [low, high). If high is None (the ......
Read more >Can I specify a numpy dtype when generating random values?
Q: is it possible to specify a dtype for random numbers when I create them. A: No it isn't. randn accepts the shape...
Read more >Random sampling in numpy | randint() function - GeeksforGeeks
numpy.random.randint() is one of the function for doing random sampling in numpy. It returns an array of specified shape and fills it with ......
Read more >How to Use NumPy random.randint() in Python
NumPy random.randint() function in Python is used to return random integers from the values specified with low (inclusive) to high ...
Read more >Random Number Generator Using Numpy Tutorial - DataCamp
Random Number Generator Using Numpy Tutorial · import numpy as np np.random. · array([0.3745012, 0.95071431, 0.73199394, 0.59865848]) · heads = random_numbers < ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Someone might want floats instead of doubles, that would about double the speed.
Closing, the new API supports dtype. Please reopen if needed.