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

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. 自定义jquery表格插件

    以前一直都是再用easyui插件来实现各种功能,但是easyui太过于庞大,使用越多对服务器负载影响越大. 基于此,在模仿easyui的dataGrid表格插件的同时,自己去封装了一个.实现了基本的j ...

  2. mac上搭建svn服务器

    1.terminal 执行svnadmin create 库地址/库名,生成的即为svn库根地址. 2.修改对应目录下conf/svnserve.conf文件: anon-access = read ...

  3. html的显示消息和留言板

    <div class="inner_content"> <c:forEach items="${notices}" var="n&q ...

  4. poj 2135 Farm Tour 费用流

    题目链接 给一个图, N个点, m条边, 每条边有权值, 从1走到n, 然后从n走到1, 一条路不能走两次,求最短路径. 如果(u, v)之间有边, 那么加边(u, v, 1, val), (v, u ...

  5. asp.net mvc3 linq实现数据的增、删、改、查、

    asp.net mvc 3 linq实现数据的增.删.改.查. 添加数据 定义一个对象: public class Student { public int id{get; set;} public ...

  6. Linux的默认编码可以通过export LC_ALL=zh_CN.GBK来修改

    http://www.cnblogs.com/malecrab/p/5300486.html

  7. ImageMagick还是GraphicsMagick?

    引自:http://co63oc.blog.51cto.com/904636/328997 ImageMagick(IM) 套装包含的命令行图形工具是一主要自由软件:Linux,其他类Unix操作系统 ...

  8. dump文件定位程序崩溃代码行

    1.dump文件 2.程序对应的pdb 步骤一:安装windbg 步骤二:通过windbg打开crash dump文件 步骤三:设置pdb文件路径,即符号表路径 步骤四:运行命令!analyze -v ...

  9. Shortest Prefixes(trie树唯一标识)

    Shortest Prefixes Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 15948   Accepted: 688 ...

  10. android程序报错“error launching activity com.android.ddmlib.shellcommandunresponsiveexception”的解决方式

    今天在调试android程序的时候,因为是NDK开发,要先编译.so库再打包下载到android模拟器,所以花费的时间比較长.控制台就会报例如以下错误: error launching activit ...