Create array with Random Numbers
Create array with Random Numbers with random module of Numpy library.
In this Numpy tutorial we are creating two arrays of random numbers. First one with random numbers from uniform distribution and second one where random numbers are from normal distribution.
# Imports
import numpy as np
# Let's build array of random numbers
arr = np.random.rand(2,3)
arr
array([[ 0.93478063, 0.42155196, 0.84486895], [ 0.29931957, 0.34730261, 0.37111244]])
# Random numbers from normal distribution
array_n = np.random.randn(2,3)
array_n
array([[-0.15518876, -0.17738767, -1.11339571], [-1.14957402, -1.45929511, 0.85649973]])
Related Resources:
- Numpy Arange Create an Array | Numpy tutorial Numpy Arange Use numpy arange method to create array with sequence of numbers. In the below example we create an...
- Reshape Numpy array | Numpy Tutorial Reshape Numpy Array Reshape numpy array with “reshape” method of numpy library. Reshaping numpy array is useful to convert array...
- Get value from index in Numpy array | Numpy tutorial Value from Index in Numpy Get value from index in numpy array using python like slicing. In below examples we...
- Create Vector in Python | Numpy Tutorial Create a Vector Create a Vector in Python using numpy array objects and reshape method. Vectors are backbone of math...
- Learn Numpy with mini tutorials Numpy Learn Numpy with easy mini tutorials. Numpy is a scientific computing package. Numpy operations are highly optimized therefore handling...
- Reverse Numpy array | Various strategies Reverse Numpy arrays Reverse 1 dimensional numpy arrays using reverse slicing [ : :-1] Reverse N dimensional numpy arrays row wise using...
- Save Numpy array to csv file Save Numpy array to csv file Most machine learning engineers and Data Scientists use Numpy array because it’s efficient and...
- Get Numpy array dimensions Find Numpy array dimensions Shape attribute of numpy can be used to find dimensions of numpy array easily. # Imports...
- Read csv file to numpy array Read csv file to numpy array Use “savetxt” method of numpy to save a numpy array to csv file Use...
- Rank of a Matrix | Numpy tutorial Rank of a Matrix Find Rank of a Matrix using “matrix_rank” method of “linalg” module of numpy. Rank of a...