我已经对数据进行分箱以绘制直方图。因此,我正在使用该plt.bar()功能。我想将绘图中的两个轴都设置为对数刻度。
如果设置plt.bar(x, y, width=10, color='b', log=True),则可以将y轴设置为log,但不能设置x轴为对数。plt.xscale('log')不幸的是,我尝试了这种方法。x轴刻度消失,条形的大小没有相等的宽度。
我将不胜感激。
不幸的是,当我尝试使用标准lognorm.pdf()时,拟合分布的形状非常不同。我想这是因为我的数据已经分箱了。这是代码:
times, data, bin_points = ReadHistogramFile(filename)
xmin = 200
xmax = 800
x = np.linspace(xmin, xmax, 1000)
shape, loc, scale = stats.lognorm.fit(data, floc=0)
pdf = stats.lognorm.pdf(x, shape, loc=loc, scale=scale)
area=data.sum()
plt.bar(bars, data, width=10, color='b')
plt.plot(x*area, pdf, 'k' )
Run Code Online (Sandbox Code Playgroud)
这是拟合分布的样子:
显然,缩放也有问题。不过我不太关心这个。我的主要问题是分布的形状。这可能与:this question但我找不到正确的解决方案重复。我试过了,仍然得到与上述操作非常相似的形状。谢谢你的帮助!
更新:
通过使用curve_fit()我能够得到一些适合。但我还不满意。我想要原始垃圾箱而不是统一垃圾箱。此外,我不确定到底发生了什么,以及是否没有更合适的。这是代码:
def normalize_integral(data, bin_size):
normalized_data = np.zeros(size(data))
print bin_size
sum = data.sum()
integral = bin_size*sum
for i in range(0, size(data)-1):
normalized_data[i] = data[i]/integral
print 'integral:', normalized_data.sum()*bin_size
return normalized_data
def pdf(x, mu, …Run Code Online (Sandbox Code Playgroud) 当我编译包含设计C++ 11的以下代码时,我得到错误 - 它不编译.我试过不同的旗帜,但我还没有找到解决方案.
我的设置:CUDA 6.5,gcc 4.4.7我无法更改设置.我怎么还能做这个工作?
#include <stdio.h>
#include <vector>
#include "KD_tree.h"
#include "KD_tree.cpp"
#include <iostream>
#include <algorithm>
#include <cmath>
#include <future>
#define MYDEVICE 0
using namespace std;
int main()
{
//do something.....
cudaDeviceProp devProp;
cudaGetDeviceProperties(&devProp, MYDEVICE);
printDevProp(devProp);
int max_threads = devProp.warpSize;
//do something else ...
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我尝试使用不同的标志进行编译:
nvcc -std=c++11 cudaMain.cu KD_tree.cpp -arch=sm_20 -o tree.out
In file included from cudaMain.cu:14:
simple_kd_tree.h:12:19: warning: extra tokens at end of #include directive
cudaMain.cu:19:18: error: future: No such file or directory …Run Code Online (Sandbox Code Playgroud)