Answers for "numpy random array in range"

1

numpy random float array between 0 and 1

# Returns an array of floats between 0 and 10 of size 15
np.random.uniform(low=0, high=10, size=15)
Posted by: Guest on May-11-2020
2

generate random integer matrix python

import numpy as np

randi_arr = np.random.randint(start, end, dimensions)
#random integers will be sampled from [start, end) (end not inclusive)
#end is optional; if end is not specified, random integers will be sampled from [0, start) (start not inclusive)
#dimensions can be specified as shown here; (m,n) #2D array with size 'm x n'
Posted by: Guest on September-01-2020
0

create numpy table with random values in range

import numpy as np

# if the shape is not mentioned the output will just be a random integer in the given range
rand_int = np.random.randint(5,10)  
print("First array", rand_int)

rand_int2 = np.random.randint(10,90,(4,5)) # random numpy array of shape (4,5)
print("Second array", rand_int2)

rand_int3 = np.random.randint(50,75,(2,2), dtype='int64')
print("Third array", rand_int3)
Posted by: Guest on August-30-2021

Code answers related to "numpy random array in range"

Python Answers by Framework

Browse Popular Code Answers by Language