Python data visualization normal distribution simple analysis and implementation code, python Visualization

Source: Internet
Author: User

Python data visualization normal distribution simple analysis and implementation code, python Visualization

Python is simple but not simple, especially when combined with high numbers...

Normaldistribution, also known as "Normal Distribution", also known as Gaussiandistribution, was first obtained by A. momowt in the formula for finding the two-term distribution. C. F. Gauss derives the measurement error from another angle. P.S. Laplace and Gauss study its properties. It is a probability distribution that is very important in mathematics, physics and engineering, and has a significant influence in many aspects of statistics.

The normal curve is bell-shaped, the two sides are low, the middle is high, and the left and right symmetry is called a bell-shaped curve because the curve is bell-shaped.

If the random variable X follows a normal distribution where the expected mathematical value is μ and the variance is σ ^ 2, it is recorded

N (μ, σ ^ 2)

The probability density function determines its location based on the expected value μ of the normal distribution, and its standard deviation σ determines the distribution range. When μ = 0, σ = 1, the normal distribution is the standard normal distribution. Its probability density function is:


The standard normal distribution we usually call a normal distribution:


Probability Density Function



Code implementation:

# Python implementation of normal distribution
 # Draw normal distribution probability density function
 u = 0 # mean μ
 u01 = -2
 sig = math.sqrt (0.2) # standard deviation δ
 sig01 = math.sqrt (1)
 sig02 = math.sqrt (5)
 sig_u01 = math.sqrt (0.5)
 x = np.linspace (u-3 * sig, u + 3 * sig, 50)
 x_01 = np.linspace (u-6 * sig, u + 6 * sig, 50)
 x_02 = np.linspace (u-10 * sig, u + 10 * sig, 50)
 x_u01 = np.linspace (u-10 * sig, u + 1 * sig, 50)
 y_sig = np.exp (-(x-u) ** 2 / (2 * sig ** 2)) / (math.sqrt (2 * math.pi) * sig)
 y_sig01 = np.exp (-(x_01-u) ** 2 / (2 * sig01 ** 2)) / (math.sqrt (2 * math.pi) * sig01)
 y_sig02 = np.exp (-(x_02-u) ** 2 / (2 * sig02 ** 2)) / (math.sqrt (2 * math.pi) * sig02)
 y_sig_u01 = np.exp (-(x_u01-u01) ** 2 / (2 * sig_u01 ** 2)) / (math.sqrt (2 * math.pi) * sig_u01)
 plt.plot (x, y_sig, "r-", linewidth = 2)
 plt.plot (x_01, y_sig01, "g-", linewidth = 2)
 plt.plot (x_02, y_sig02, "b-", linewidth = 2)
 plt.plot (x_u01, y_sig_u01, "m-", linewidth = 2)
 # plt.plot (x, y, 'r-', x, y, 'go', linewidth = 2, markersize = 8)
 plt.grid (True)
 plt.show () 

Summary

The above is all about simple analysis of Python data visualization normal distribution and code implementation, and I hope to help you. If you are interested, you can continue to refer to otherPythonAndAlgorithmRelated Topics. If you have any shortcomings, please leave a message. Thank you for your support!


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.