f として定義された関数を scipy の odeint を使用してコードに統合しようとしています。関数 f は引数として theta、t、および K を取り、これらは関数 f の下で定義されます。y は結果であり、エラーが発生しています。エラーの理由は、2 次元のシータです。統合を実行できません。誰かがこれで私を助けてくれますか?
import numpy as np
import random
from scipy.integrate import odeint
f
統合する機能です
def f(theta, t, K):
global N
tau = 1.5
dtheta = np.zeros([T,N], float)
for i in range(N):
s = 0.
for j in range(i+1,N):
s = s + np.sin(theta[t-tau,j] - theta[t,i])
dtheta[t,i] = K*s
return dtheta
# Number of nodes
N = 10
# Constant
K = 1.0
# Number of time steps
T = 100
t = np.linspace(0, T, 100, endpoint=False)
theta = np.zeros([T,N], float)
乱数を一様に生成
for i in range(N):
theta[0,i] = random.uniform(-180, 180)
fromf
を使用して関数を統合するodeint
scipy
y = odeint(f, theta, t, args=(K,))
print y