本人最近在写一篇关于神经网络同步的文章,其一部分模型为:

x_i^{\Delta}(t)= -a_i*x_i(t)+ b_i* f(x_i(t))+ \sum\limits_{j \in\{i-1, i+1\}}c_{ij}f(x_j(t-\tau_{ij})), t\in\mathbb{R}    (1.1)

y_i^{\Delta}(t)= -a_i*y_i(t)+ b_i* f(y_i(t))+ \sum\limits_{j \in\{i-1, i+1\}}c_{ij}f(y_j(t-\tau_{ij})), t\in\mathbb{R}    (1.2)

下面利用python求(1.1)-(1.2)的数值解并作出图形:

# Numerical simulation for 3-rd paper
# Author: Qiang Xiao
# Time: 2015-06-22 import matplotlib.pyplot as plt
import numpy as np a= 0.5
b= -0.5
c= 0.5
tau= 1
k= 2
delta= 0.1
T= 200
row= 6
col= int(T/delta)
N= 6 x= np.zeros((row, col))
dx= np.zeros((row, col))
y= np.zeros((row, col))
dy= np.zeros((row, col)) x0= [5,2,1,0,1,4]
y0= [-5,2,-3,-2,0,-3]
for i in range(N):
x[i,0:int(tau/delta)+ 1]= x0[i]
y[i,0:int(tau/delta)+ 1]= y0[i] print np.e def f(t):
return np.cos(t) def j(i):
if i== 0:
  return 1, 5
elif i== 5:
  return 4, 0
else:
   return i-1, i+1 for time in range(int(tau/delta),int(T/delta)-1):
for i in range(6):
  dx[i, time]= -a* x[i, time]+ b*f(x[i, time])+ c*f(x[int(j(i)[0]), time- 10])+ c*f(x[int(j(i)[1]), time- 10])
  dy[i, time]= -a* y[i, time]+ b*f(y[i, time])+ c*f(y[int(j(i)[0]), time- 10])+ c*f(y[int(j(i)[1]), time- 10])+ k*(x[i, time]- y[i, time])
x[i, time+1]= x[i, time]+ delta*dx[i, time]
y[i, time+1]= y[i, time]+ delta*dy[i, time] tt= np.arange(tau,T,delta)
print len(tt) plt.plot(tt,x[0,10:int(T/delta)],'c')
plt.plot(tt,y[0,10:int(T/delta)],'c.')
plt.plot(tt,x[1,10:int(T/delta)],'r.')
plt.plot(tt,y[1,10:int(T/delta)],'r')
plt.plot(tt,x[2,10:int(T/delta)],'b')
plt.plot(tt,y[2,10:int(T/delta)],'b.')
plt.plot(tt,x[3,10:int(T/delta)],'k')
plt.plot(tt,y[3,10:int(T/delta)],'k.')
plt.plot(tt,x[4,10:int(T/delta)],'m')
plt.plot(tt,y[4,10:int(T/delta)],'m.')
plt.plot(tt,x[5,10:int(T/delta)],'y')
plt.plot(tt,y[5,10:int(T/delta)],'y.') plt.xlabel('Time t')
plt.ylabel('xi(t) and yi(t)')
plt.legend(('x1','y1','x2','y2','x3','y3','x4','y4','x5','y5','x6','y6'))
plt.show()

由上图可以看出,网络单元x_i(t) 与 y_i(t) 分别达成了同步。

欢迎交流!

python求微分方程组的数值解曲线01的更多相关文章

  1. Python小白的数学建模课-05.0-1规划

    0-1 规划不仅是数模竞赛中的常见题型,也具有重要的现实意义. 双十一促销中网购平台要求二选一,就是互斥的决策问题,可以用 0-1规划建模. 小白学习 0-1 规划,首先要学会识别 0-1规划,学习将 ...

  2. 使用python求字符串或文件的MD5

    使用python求字符串或文件的MD5 五月 21st, 2008 #以下可在python3000运行. #字符串md5,用你的字符串代替'字符串'中的内容. import hashlib md5=h ...

  3. Python 求点到直线的垂足

    Python 求点到直线的垂足 在已知一个点,和一条已知两个点的直线的情况下 运算公式参考链接:https://www.cnblogs.com/mazhenyu/p/3508735.html def ...

  4. python求100以内素数

    python求100以内素数之和 from math import sqrt # 使用isPrime函数 def isPrime(n): if n <= 1: return False for ...

  5. MATLAB求微分

    求微分 diff(函数) , 求的一阶导数;diff(函数, n) , 求的n阶导数(n是具体整数);diff(函数,变量名), 求对的偏导数;diff(函数, 变量名,n) ,求对的n阶偏导数; & ...

  6. Python 求两个文本文件以行为单位的交集 并集 差集

    Python 求两个文本文件以行为单位的交集 并集 差集,来代码: s1 = set(open('a.txt','r').readlines()) s2 = set(open('b.txt','r') ...

  7. python求极值点(波峰波谷)

    python求极值点主要用到scipy库. 1. 首先可先选择一个函数或者拟合一个函数,这里选择拟合数据:np.polyfit import pandas as pd import matplotli ...

  8. Python求一个数字列表的元素总和

    Python求一个数字列表的元素总和.练手: 第一种方法,直接sum(list): 1 lst = list(range(1,11)) #创建一个1-10的数字列表 2 total = 0 #初始化总 ...

  9. python求线性回归斜率

    一. 先说我对这个题目的理解 直线的x,y方程是这样的:y = kx+b, k就是斜率. 求线性回归斜率, 就是说 有这么一组(x, y)的对应值——样本.如果有四组,就说样本量是4.根据这些样本,做 ...

随机推荐

  1. JS学习之事件冒泡

    (1)什么是事件起泡      首先你要明白一点,当一个事件发生的时候,该事件总是有一个事件源,即引发这个事件的对象,一个事件不能凭空产生,这就是事件的发生. 当事件发生后,这个事件就要开始传播.为什 ...

  2. 5.5 Function类型

    说起来ECMAScript中上面最有意思,我想那莫过于函数了,有意思的根源,则在于函数实际上是对象.每个函数都是Function类型的实例,而且都与其他引用类型一样具有属性和方法.由于函数是对象,因此 ...

  3. [LeetCode]题解(python):007-Reverse Integer

    题目来源: https://leetcode.com/problems/reverse-integer/ 题意分析: 这道题目很简单,就是将一个数反转,123变321,-123变321. 题目思路: ...

  4. MVC-04 视图(1)

    不可否认的,View应该是整个ASP.NET MVC项目开发过程中最花时间的部分,因为与显示逻辑相关的技术五花八门,你可能要学习的有HTML.CSS.JavaScript.DOM.JQuery.JSO ...

  5. Java ThreadLocal 学习

    同步机制是为了同步多个线程对相同资源的并发访问,是为了多个线程之间进行通信的有效方式. 而ThreadLocal是隔离多个线程的数据共享,从根本上就不在多个线程之间共享资源(变量),这样当然不需要对多 ...

  6. NSDate conversion utilities

    // Gets UTC NSDate from DateTime(.Net/WCF). + (NSDate *)fromDateTime:(NSString *)dateTime { NSDate * ...

  7. Android的电源管理框架

    Android的电源管理框架 Android通过锁和定时器来切换系统的状态,使系统的功耗降至最低,整个系统的电源管理框架分成五个部分:应用层,framework层,JNI层,HAL层和内核层.电源管理 ...

  8. 碰撞缓冲效果的导航条 js

  9. C# Best Practices - Handling Strings

    Features Strings Are Immutable. A String Is a Reference Type Value Type Store their data directly Ex ...

  10. tomcat使用所遇到的问题

    1.在使用eclipse添加server的时候添加不了tomcat服务器: 如图左图所示,添加按钮已成灰色,无法操作. 解决办法:找到workspace的工作空间->.metadata-> ...