Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/319.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 将现有numpy直方图转换为boost直方图_Python_Numpy_Boost_Boost Histogram - Fatal编程技术网

Python 将现有numpy直方图转换为boost直方图

Python 将现有numpy直方图转换为boost直方图,python,numpy,boost,boost-histogram,Python,Numpy,Boost,Boost Histogram,我有很多工作要做。它们中的每一个都是这样创建的: bin_height, bin_edges = np.histogram(data) 什么是将其转化为的最佳方法?此解决方案是由以下人员向我提出的: 请注意,如果尚未创建直方图,则bhist=bh.numpy.histogram(数据,histogram=bh.histogram)是更好的解决方案。bhist[:]=bin_height从0.6或0.7开始受支持。 import boost_histogram as bh import num

我有很多工作要做。它们中的每一个都是这样创建的:

bin_height, bin_edges = np.histogram(data)


什么是将其转化为的最佳方法?

此解决方案是由以下人员向我提出的:


请注意,如果尚未创建直方图,则
bhist=bh.numpy.histogram(数据,histogram=bh.histogram)
是更好的解决方案。
bhist[:]=bin_height
从0.6或0.7开始受支持。
import boost_histogram as bh
import numpy as np
import matplotlib.pyplot as plt

# generate some randome data
rng = np.random.RandomState(10)
data = rng.normal(size=1000)

#create numpy histogram
bin_height, bin_edges = np.histogram(data)

#turn it into a boost-histogram
bhist = bh.Histogram(bh.axis.Variable(bin_edges))
bhist.view()[:] = bin_height

#plot it
plt.bar(bhist.axes[0].centers, bhist.view(), width=bhist.axes[0].widths);