Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Python Tutorial
  • Interview Questions
  • Python Quiz
  • Python Glossary
  • Python Projects
  • Practice Python
  • Data Science With Python
  • Python Web Dev
  • DSA with Python
  • Python OOPs
Open In App
Next Article:
Normal Distribution in NumPy
Next article icon

Normal Distribution in NumPy

Last Updated : 23 Apr, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

The Normal Distribution also known as the Gaussian Distribution is one of the most important distributions in statistics and data science. It is widely used to model real-world phenomena such as IQ scores, heart rates, test results and many other naturally occurring events.

numpy.random.normal() Method

In Python's NumPy library we can generate random numbers following a Normal Distribution using the numpy.random.normal() method. It has three key parameters:

  1. loc : Specifies the center (mean) of the distribution, where the peak of the bell curve exists.
  2. scale : Determines the spread (standard deviation) of the distribution controlling how flat or narrow the graph is.
  3. size : Defines the shape of the returned array.

Syntax :

numpy.random.normal(loc=0.0, scale=1.0, size=None)

Example 1: Generate a Single Random Number

To generate a single random number from a default Normal Distribution (loc=0, scale=1):

Python
import numpy as np  random_number = np.random.normal() print(random_number) 

Output:

0.013289272641035141

Example 2: Generate an Array of Random Numbers

To generate multiple random numbers

Python
random_numbers = np.random.normal(size=5) print(random_numbers) 

Output:

[ 1.44819595 0.90517495 -0.75923069 0.50357022 -0.34776612]

Visualizing the Normal Distribution

Visualizing the generated numbers helps in understanding their behavior. Below is an example of plotting a histogram of random numbers generated using numpy.random.normal.

Python
import numpy as np import matplotlib.pyplot as plt  data = np.random.normal(loc=0, scale=1, size=1000)  plt.hist(data, bins=30, edgecolor='black', density=True) pdf = norm.pdf(x, loc=loc, scale=scale)   plt.plot(x, pdf, color='red', label='Theoretical PDF') plt.title("Normal Distribution") plt.xlabel("Value") plt.ylabel("Density") plt.grid(True) plt.show() 

Output:

Normal-Distribution
Normal Distribution

The histogram represents the frequency of the generated numbers and the curve shows the theoretical pattern for comparison. The curve of a Normal Distribution is also known as the Bell Curve because of the bell-shaped curve.


Next Article
Normal Distribution in NumPy

A

ayushimalm50
Improve
Article Tags :
  • Python
  • Numpy
  • python
Practice Tags :
  • python
  • python

Similar Reads

    Python - Normal Distribution in Statistics
    A probability distribution determines the probability of all the outcomes a random variable takes. The distribution can either be continuous or discrete distribution depending upon the values that a random variable takes. There are several types of probability distribution like Normal distribution,
    6 min read
    Normal Distribution Plot using Numpy and Matplotlib
    In this article, we will see how we can create a normal distribution plot in python with numpy and matplotlib module. What is Normal Distribution?Normal Distribution is a probability function used in statistics that tells about how the data values are distributed. It is the most important probabilit
    2 min read
    Python - Power Normal Distribution in Statistics
    scipy.stats.powernorm() is a power normal continuous random variable. It is inherited from the of generic methods as an instance of the rv_continuous class. It completes the methods with details specific for this particular distribution. Parameters : q : lower and upper tail probability x : quantile
    2 min read
    How to Create a Normal Distribution in Python PyTorch
    In this article, we will discuss how to create Normal Distribution in Pytorch in Python. torch.normal() torch.normal() method is used to create a tensor of random numbers. It will take two input parameters. the first parameter is the mean value and the second parameter is the standard deviation (std
    2 min read
    NumPy Introduction
    NumPy(Numerical Python) is a fundamental library for Python numerical computing. It provides efficient multi-dimensional array objects and various mathematical functions for handling large datasets making it a critical tool for professionals in fields that require heavy computation.Table of ContentK
    7 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences