Generating Normal Distribution Data with NumPy

  • Share this:

Code introduction


This function uses the NumPy library to generate random data following a normal distribution.


Technology Stack : NumPy, SciPy

Code Type : Dagster Custom Function

Code Difficulty : Intermediate


                
                    
import random
import numpy as np
import pandas as pd
from scipy.stats import norm

def generate_normal_distribution_data(mean, std_dev, size):
    """
    Generates random data following a normal distribution.
    
    :param mean: Mean of the normal distribution
    :param std_dev: Standard deviation of the normal distribution
    :param size: Number of samples to generate
    :return: A numpy array of random samples
    """
    return np.random.normal(mean, std_dev, size)                
              
Tags: