import numpy as np
import matplotlib.pyplot as plt
import math
# Python实现正态分布
# 绘制正态分布概率密度函数
u = 0 # 均值μ
u01 = -2
sig = math.sqrt(0.2) # 标准差δ
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()

 

python 画正态曲线的更多相关文章

  1. 沉淀再出发:用python画各种图表

    沉淀再出发:用python画各种图表 一.前言 最近需要用python来做一些统计和画图,因此做一些笔记. 二.python画各种图表 2.1.使用turtle来画图 import turtle as ...

  2. python画樱花

    用python画简单的樱花 代码如下: import turtle as T import random import time # 画樱花的躯干(60,t) def Tree(branch, t): ...

  3. python 画小猪佩奇

    转自:python画个小猪佩奇 # -*- coding: utf-8 -*- """ Created on Mon May 20 11:36:03 2019 @auth ...

  4. 用python画 pareto front

    用python画 pareto front 觉得有用的话,欢迎一起讨论相互学习~Follow Me 2D pf import os import matplotlib.pyplot as plt im ...

  5. python 画3D的高斯曲线

    用python画3D的高斯曲线,我想如果有多个峰怎么画? import numpy as npimport matplotlib.pyplot as pltimport mathimport mpl_ ...

  6. python画一只佩奇

    用python画一只佩奇 from turtle import* def nose(x,y):#鼻子 penup()#提起笔 goto(x,y)#定位 pendown()#落笔,开始画 sethead ...

  7. 利用python画出动态高优先权优先调度

    之前写过一个文章. 利用python画出SJF调度图 动态高度优先权优先调度 动态优先权调度算法,以就绪队列中各个进程的优先权作为进程调度的依据.各个进程的优先权在创建进程时所赋予,随着进程的推进或其 ...

  8. 【python画圆】pip安装库时出现Read timed out.解决办法

    昨天第一次用python画圆,当时并没有安装numpy库(导入数据包)和matplotlib库(导入图形包),于是尝试用pip安装库 首先,我先更新了pip,如下图: 顺便附上成功截图: 然后安装nu ...

  9. python画柱状图并且输出到html文件

    import matplotlibmatplotlib.use('Agg')import matplotlib.pyplot as pltfrom Cstring import StringIO y ...

随机推荐

  1. Flutter移动电商实战 --(18)首页_火爆专区商品接口制作

    1.获取接口的方法 在service/service_method.dart里制作方法.我们先不接收参数,先把接口调通. Future getHomePageBeloConten() async{ t ...

  2. 客户端配置代理服务实现yum上外网

    vi  /etc/profile http_proxy=http://172.20.188.193:3128/https_proxy=https://172.20.188.193:3128/expor ...

  3. PyTorch Tutorials 1 PyTorch是什么?

    %matplotlib inline PyTorch是什么? 基于Python的科学计算包,服务于以下两种场景: 作为NumPy的替代品,可以使用GPU的强大计算能力 提供最大的灵活性和高速的深度学习 ...

  4. 十个Python爬虫武器库示例,十个爬虫框架,十种实现爬虫的方法!

    一般比价小型的爬虫需求,我是直接使用requests库 + bs4就解决了,再麻烦点就使用selenium解决js的异步 加载问题.相对比较大型的需求才使用框架,主要是便于管理以及扩展等. 1.Scr ...

  5. Eclipse项目修改编译jdk版本(Failed to read candidate component class: file 处理)

    转: Failed to read candidate component class: file 处理 2018年03月09日 07:15:54 爱萨萨 阅读数 10041   出错现象: org. ...

  6. es6 map()和filter()详解【转】

    原文地址:http://www.zhangxinxu.com/wordpress/2013/04/es5%e6%96%b0%e5%a2%9e%e6%95%b0%e7%bb%84%e6%96%b9%e6 ...

  7. k8s install kubeadm网络原因访问不了谷哥and gpg: no valid OpenPGP data found. 解决办法

    gpg: no valid OpenPGP data found. 解决办法 待做.................................... 卡助在这curl -s https://pa ...

  8. Spring Aop(十四)——Aop自动创建代理对象的原理

    转发地址:https://www.iteye.com/blog/elim-2398725 Aop自动创建代理对象的原理 我们在使用Spring Aop时,通常Spring会自动为我们创建目标bean的 ...

  9. windows下初安装xgboost

    1.先检查一下自己的版本,如图python3.6,win64 我的之前环境是已经安装了anaconda. 2.去相关的网站下载 3.把下载的文件拷到此目录下(同pip在一个目录下) 4.cmd在此目录 ...

  10. shell之判断文件是否存在

    #!/bin/sh myPath="/var/log/httpd/" myFile="/var /log/httpd/access.log" #这里的-x 参数 ...