English 中文(简体)
SciPy interp1d 结果不同于MatLab Interp1
原标题:SciPy interp1d results are different than MatLab interp1

I m 将“MatLab”方案改为“Stefan”,“I m”有问题理解为什么会ip。 污染。 间谍活动取得的结果不同于MatLab Interp1。

在MatLab,使用量略有不同:

yi = interp1(x,Y,xi, cubic )

SciPy:

f = interp1d(x,Y,kind= cubic )
yi = f(xi)

For a trivial example the results are the same: MatLab:

interp1([0 1 2 3 4], [0 1 2 3 4],[1.5 2.5 3.5], cubic )
  1.5000 2.5000 3.5000

粉碎

interp1d([1,2,3,4],[1,2,3,4],kind= cubic )([1.5,2.5,3.5])
  array([ 1.5,  2.5,  3.5])

但就真正的世界而言,它们并不相同:

x =   0.0000e+000  2.1333e+001  3.2000e+001  1.6000e+004  2.1333e+004  2.3994e+004
Y =   -6   -6   20   20   -6   -6
xi =  0.00000 11.72161 23.44322 35.16484...  (2048 data points)

Matlab:

-6.0000e+000
-1.2330e+001
-3.7384e+000
  ...
 7.0235e+000
 7.0028e+000
 6.9821e+000

SciPy:

array([[ -6.00000000e+00],
       [ -1.56304101e+01],
       [ -2.04908267e+00],
       ..., 
       [  1.64475576e+05],
       [  8.28360759e+04],
       [ -5.99999999e+00]])

对我如何能够取得与马塔克族一致的结果有什么想法?

Edit:我理解,在实行立方米污染算法方面有一些自由,这可能是我所看到的差异。 看来,我正在转换的原“MatLab”方案本应采用线性干涉,因此问题很可能是空洞的。

问题回答

<代码>scipy.interpolate.interp1d和interp1的基本污染方法不同。 假设使用净校正(fit Pack) 常规,即产生标准,C2连续立方间谍。 <代码>interp1中的“cubic”论点使用零散的立方米杂质,这些杂质不是C2连续的。 See here,用于解释Matlab所做的工作。

我怀疑这是你所看到的分歧的根源。

In current scipy use http://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.PchipInterpolator.html This will create monotonic cubic interpolation of the y=f(x) passed, and uses the pchip algorithm to determine the slopes in the points.

因此,每节(x,y)由您通过,计算(x,dy/dx)时,只有两立方位,在这两点都有已知的衍生物。 每个建筑工程将连续进行第一次衍生产品。





相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签