Python Practice › NumPy Programs › Program 22

Five standard normal numbers

EasyNumPy Programs · 22 of 100

Write a NumPy program to generate 5 random numbers from a standard normal distribution.

Advertisement
Output
[ 0.001  0.299 -0.274 -0.891 -0.455]

Approach

  1. rng.standard_normal(5).

Solution

Python
import numpy as nprng = np.random.default_rng(7)print(rng.standard_normal(5).round(3))
Output
[ 0.001  0.299 -0.274 -0.891 -0.455]

Learn the concept

New to this topic? Read the lesson, then come back.

More numpy programs

← All 100 NumPy Programs

Leave a Comment