我在下面有以下代码,用于打印特定平均值和标准偏差的 PDF 图表。
现在我需要找到特定值的实际概率。例如,如果我的均值是 0,我的值是 0,我的概率是 1。这通常是通过计算曲线下的面积来完成的。与此类似:
http://homepage.divms.uiowa.edu/~mbognar/applet/normal.html
我不知道如何解决这个问题
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
def normal(power, mean, std, val):
a = 1/(np.sqrt(2*np.pi)*std)
diff = np.abs(np.power(val-mean, power))
b = np.exp(-(diff)/(2*std*std))
return a*b
pdf_array = []
array = np.arange(-2,2,0.1)
print array
for i in array:
print i
pdf = normal(2, 0, 0.1, i)
print pdf
pdf_array.append(pdf)
plt.plot(array, pdf_array)
plt.ylabel('some numbers')
plt.axis([-2, 2, 0, 5])
plt.show()
print
Run Code Online (Sandbox Code Playgroud) 我想在其他地图中锁定键/索引,如下所示:
std::map<int, boost::mutex> pointCloudsMutexes_;
pointCloudsMutexes_[index].lock();
Run Code Online (Sandbox Code Playgroud)
但是,我收到以下错误:
/usr/include/c++/4.8/bits/stl_pair.h:113: error: no matching function for call to 'boost::mutex::mutex(const boost::mutex&)'
: first(__a), second(__b) { }
^
Run Code Online (Sandbox Code Playgroud)
它似乎可以使用std::vector,但不是std::map.我究竟做错了什么?