非常小的花车上的 Numpy 直方图
Numpy Histogram over very tiny floats
我有一个带有小浮点数的数组,这里是一个豁免:
[-0.000631510156545283, 0.0005999252334386763, 2.6784775066479167e-05,
-6.171351407584846e-05, -2.0256783283654057e-05, -5.700196588437318e-05,
0.0006830172130385885, -7.862102776837944e-06, 0.0008167604859504389,
0.0004497656945683915, -0.00017132944173890756, -0.00013510823579343265,
0.00019666267095029728, -9.0271602657355e-06, 0.0005219852103996746,
4.010928726736523e-05, -0.0005287787999295592, 0.00023883106926381664,
0.0006348661301799839, 0.0003881285984411852]
(编辑:整个数组包含 ~40k 浮点数)
这些数字显示测量值随时间的变化,例如+0.0001 表示测量值增加 0.0001。
我想绘制整个数组的直方图。目前,pyplot.hist
创建一个图,将所有值插入一个 bin 中(This image shows the current histogram.,使用以下代码创建(已编辑):
import matplotlib.pyplot as plt
fig, axs = plt.subplots(1, 1, figsize=(20,20))
array = [] # floats here
axs.hist(array,bins=10)
axs.set_ylabel("Histogram of temperature/weight ratio")
axs.set_xlabel("Bins")
)。
我猜这是因为人数太少了 - 我就在这里吗?
我尝试使用 hist, bins = numpy.histogram()
绘制它,结果相同。 (在这个问题之后here)。
我如何为如此小的数字创建直方图,以便将值分布在例如100 个箱子,并没有全部插入第一个箱子?我需要预处理我的数据吗?
其他寻求答案的人:
正如 Jody Klymak 在对我的问题的评论中所建议的那样,手动指定垃圾箱。
我不需要进一步预处理数据,因为我认为我必须这样做。
示例:
import matplotlib.pyplot as plt
import bumpy as np
array = [...] # large array with tiny floats
fig, axs = plt.subplots(1, 1, figsize=(20,20))
hist = axs.hist(array, np.arange(-0.01, 0.01, 0.0001)) #numpy to create bins over range
plt.show()
我有一个带有小浮点数的数组,这里是一个豁免:
[-0.000631510156545283, 0.0005999252334386763, 2.6784775066479167e-05,
-6.171351407584846e-05, -2.0256783283654057e-05, -5.700196588437318e-05,
0.0006830172130385885, -7.862102776837944e-06, 0.0008167604859504389,
0.0004497656945683915, -0.00017132944173890756, -0.00013510823579343265,
0.00019666267095029728, -9.0271602657355e-06, 0.0005219852103996746,
4.010928726736523e-05, -0.0005287787999295592, 0.00023883106926381664,
0.0006348661301799839, 0.0003881285984411852]
(编辑:整个数组包含 ~40k 浮点数)
这些数字显示测量值随时间的变化,例如+0.0001 表示测量值增加 0.0001。
我想绘制整个数组的直方图。目前,pyplot.hist
创建一个图,将所有值插入一个 bin 中(This image shows the current histogram.,使用以下代码创建(已编辑):
import matplotlib.pyplot as plt
fig, axs = plt.subplots(1, 1, figsize=(20,20))
array = [] # floats here
axs.hist(array,bins=10)
axs.set_ylabel("Histogram of temperature/weight ratio")
axs.set_xlabel("Bins")
)。 我猜这是因为人数太少了 - 我就在这里吗?
我尝试使用 hist, bins = numpy.histogram()
绘制它,结果相同。 (在这个问题之后here)。
我如何为如此小的数字创建直方图,以便将值分布在例如100 个箱子,并没有全部插入第一个箱子?我需要预处理我的数据吗?
其他寻求答案的人:
正如 Jody Klymak 在对我的问题的评论中所建议的那样,手动指定垃圾箱。 我不需要进一步预处理数据,因为我认为我必须这样做。
示例:
import matplotlib.pyplot as plt
import bumpy as np
array = [...] # large array with tiny floats
fig, axs = plt.subplots(1, 1, figsize=(20,20))
hist = axs.hist(array, np.arange(-0.01, 0.01, 0.0001)) #numpy to create bins over range
plt.show()