私はPythonでNumpyを使用して自動ビンサイズのヒストグラムを計算しようとしています。 documentationの私の読書は、私がbins="auto"
を渡すことができなければならないことを言いますが、私はそうするとき、私はエラーを取得する:numpy.histogramと "list assignment index out of range"
import sys
import numpy as np
print(sys.version)
# 2.7.10 (default, Oct 23 2015, 19:19:21)
# [GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)]
print(np.version.version)
# 1.8.0rc1
print(np.histogram([1, 2, 3, 4], bins='auto'))
# Traceback (most recent call last):
# File "/Users/phrogz/Code/histopy/histo.py", line 11, in <module>
# print(np.histogram([1, 2, 3, 4], bins='auto'))
# File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/lib/function_base.py", line 183, in histogram
# if (np.diff(bins) < 0).any():
# File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/lib/function_base.py", line 991, in diff
# slice1[axis] = slice(1, None)
# IndexError: list assignment index out of range#
#
# Process finished with exit code 1
期待どおりに動作しますが、私は、bins
のための任意の文字列パラメータと同じ結果を得ますパラメータの整数を指定した場合。私は間違って何をしていますか?また、自動ビンサイズの計算方法を教えてください。
トレースバックを取得したので、これをデバッグできます。外見には自信がありますが、理由は分かりません。 –