1

我想插入一些数据,并将结果绘制在对数刻度 ( pyplot.loglog) 上。问题是生成的插值看起来很奇怪,并且在对数刻度上绘制时显示不连续性。插入对数缩放数据的最佳方法是什么?

pyplot.loglog(x, y, '+')
pyplot.hold(True)
s = scipy.interpolate.InterpolatedUnivariateSpline(x, y)
xs = numpy.logspace(numpy.log10(numpy.min(x)), numpy.log10(numpy.max(x)))
pyplot.loglog(xs, s(xs)) # This looks very strange because of the log scale!

实际上,我通过插入数据日志成功地做到了这一点,但我想知道是否有更简单的方法可以实现相同的结果?

pyplot.loglog(x, y, '+')
pyplot.hold(True)
s = scipy.interpolate.InterpolatedUnivariateSpline(numpy.log10(x), numpy.log10(y))
xs = numpy.logspace(numpy.log10(numpy.min(x)), numpy.log10(numpy.max(x)))
pyplot.loglog(xs, numpy.power(10, s(numpy.log10(xs)))
4

1 回答 1

4

看起来像先取数据的对数,然后拟合是一种正常的方法。请参阅拟合幂律分布

于 2012-05-10T15:04:28.690 回答