Plotting normal distribution curves using Python with the help of matplotlib plotting tool;
#-*-coding:utf-8-*- """ Plotting standard normal distribution curves in python """ # ============================================================== import numpy as np import math import as plt def gd(x, mu=0, sigma=1): """Calculate the value of the dependent variable from the independent variable x according to the equation Argument. x: array Input data (independent variable) mu: float Mean value sigma: float Variance """ left = 1 / ((2 * ) * (sigma)) right = (-(x - mu)**2 / (2 * sigma)) return left * right if __name__ == '__main__': # Independent variables x = (-4, 5, 0.1) # Dependent variable (different means or variances) y_1 = gd(x, 0, 0.2) y_2 = gd(x, 0, 1.0) y_3 = gd(x, 0, 5.0) y_4 = gd(x, -2, 0.5) # Mapping (x, y_1, color='green') (x, y_2, color='blue') (x, y_3, color='yellow') (x, y_4, color='red') # Setting up the coordinate system (-5.0, 5.0) (-0.2, 1) ax = () ['right'].set_color('none') ['top'].set_color('none') .set_ticks_position('bottom') ['bottom'].set_position(('data', 0)) .set_ticks_position('left') ['left'].set_position(('data', 0)) (labels=['$\mu = 0, \sigma^2=0.2$', '$\mu = 0, \sigma^2=1.0$', '$\mu = 0, \sigma^2=5.0$', '$\mu = -2, \sigma^2=0.5$']) ()
Above is the use of python to draw normal distribution curve in detail, more information about python normal distribution please pay attention to my other related articles!