龙空技术网

高斯分布与高斯积分笔记

沉着糯米Su 37

前言:

目前同学们对“高斯积分系数”都比较珍视,我们都需要分析一些“高斯积分系数”的相关知识。那么小编同时在网摘上汇集了一些有关“高斯积分系数””的相关内容,希望看官们能喜欢,小伙伴们一起来了解一下吧!

Natural pertains to elements inherent to or derived from nature, unaltered by human intervention, while normal refers to what is typical, expected, or conforms to a standard.

钟形曲线是高斯/正态分布的概率密度函数(pdf: probability density function)的图像。

For a continuous random variable, the cumulative distribution function (CDF) is:

以上二式都是定积分,有上下界。用sympy求不定积分:

>>>from sympy import *>>>x = symbols('x')>>>integrate(exp(x))exp(x)>>>integrate(exp(-x))-exp(-x)>>>integrate(exp(-x**2))x*exp(x**(-2)) + I*sqrt(pi)*erf(I/x)

erf是The Gauss error function. This function is defined as:

不定积分积不出来(没有初等函数形式)。

高斯积分只能解决从-∞到∞。转换为极坐标时,如果x∈[a, b],凑不出无数个(整个的)圆。

定积分可以(近似)计算:x从a到b,Δx=0.0001,面积=底×f(x)。

以下代码修改自geeksforgeeks, How to calculate and plot a Cumulative Distribution function with Matplotlib in Python

import numpy as np import matplotlib.pyplot as plt N = 500# Get N samples from the "standard normal" distributiondata = np.random.randn(N)x = np.sort(data)# 因为x从小到大排,所以<x[i]的数量# 就是i。比如[-3, 0, 1],比[2](1)小的有2个# Get evenly spaced values within a given interval.# start默认为0,step 1。arange: array-range,# 和arrange (两个r;安排,整理,布置,排列)沾边。y = np.arange(N, dtype=float)y /= N # 化为最大为1的概率fig, axs = plt.subplots(2) # 上下2个子图# x和y两个数组要等长# plot([x], y, [fmt], *, data=None, **kwargs)# 没有x时,x看作range(len(y))axs[0].plot(x, y)### pdf及cdf方法2 ### 默认10个桶(bin)cnt, edge = np.histogram(x) # 其实输入不用有序# cnt是个数组,每个桶里的样本数# edge是data的“子集”:桶的“边”print(cnt, edge)pdf = cnt / sum(cnt)# cumulative和accumulate词根一样# cumulare 'to pile up'cdf = np.cumsum(pdf)print(pdf, cdf)# 5根指头4个指头缝, edge比cnt多1个元素x = edge[1:]axs[1].plot(x, pdf, color='red', label='pdf') axs[1].plot(x, cdf, label='CDF') plt.legend() # 图例,the words that explain a picture or map# 和“传奇; 传说”沾边,比如画上写着“汉尼拔跨过阿尔卑斯山”# 警告: 不要把legend放在在leg end处!plt.savefig('t.png')

标签: #高斯积分系数