2012-09-10 3 views
0

나는 다음과 같은 배열을 가지고 :선형 Interploation 두 배열

List_CD = [2410.412434205376, 2287.6750893063017, 2199.2602314650626, 2124.4647889960825, 2084.5846633116403, 2031.9053600816167, 1996.2844020790524, 1957.1098650203032, 1938.4110044030583, 1900.0783178367647, 1877.6396548046785, 1868.2902104714337, 1844.9165996383219, 1816.8682911816766] 
List_Dose = [10.0, 12.0, 14.0, 16.0, 18.0, 20.0, 22.0, 24.0, 26.0, 28.0, 30.0, 32.0, 34.0, 36.0] 

내가 뭘하려고 오전 사용하여 간단한 보간을하는 것입니다 :

dsize = numpy.interp(2000., List_CD, List_Dose) 

20.0과 사이에 기대하는 결과를 22.0 그러나 나는 10.0의 가치를 계속 간다.

아무도 도와 줄 수 있니?

+0

당신은 음의 값을 기대되지 않을 것이다? – njzk2

답변

7
xp : 1-D sequence of floats 
    The x-coordinates of the data points, must be increasing. 

List_CD은 증가하지 않습니다.

다음과 같은 방법으로 정렬 할 수 있습니다 :

d = dict(zip(List_CD, List_Dose)) 
xp = sorted(d) 
yp = [d[x] for x in xp] 
numpy.interp(2000., xp, yp) 
# returns 21.791381359216665 

또는 :

order = numpy.argsort(List_CD) 
numpy.interp(2000., np.array(List_CD)[order], np.array(List_Dose)[order])