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

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. [LeetCode]题解:005-Longest Palindromic Substring优化

    题目来源和题意分析: 详情请看我的博客:http://www.cnblogs.com/chruny/p/4791078.html 题目思路: 我上一篇博客解决这个问题的时间复杂度是最坏情况是(O(n^ ...

  2. Matplotlib中文乱码

    想要分析一批数据,画出图形会比较直观.所以就搜索了一下各种软件,最终选择使用python的matplotlib.原因也是因为python使用起来比较方便,虽然R才是分析数据的首选,不过,没有R的基础, ...

  3. HeapAnalyzer

    https://www.ibm.com/developerworks/community/groups/service/html/communityview?communityUuid=4544baf ...

  4. 从51跳新唐cortex-m0学习1——思想转变

    Cortex-M0学习第一帖 序言:这里先说一下,大家在看帖子时候,可能看见字数比较多的,可能只是先大概浏览一下,之后从中挑几段大概瞅瞅,但是我要说,如果你碰到一个适合的帖子,请仔细品读,这是我在论坛 ...

  5. File类常用方法

    File类是IO中常用的类 先介绍几个常用的方法: public boolean canRead(),public boolean canWrite() 测试当前文件是否可读可写,若是则返回true ...

  6. ++i和i++哪个效率高?

    这个问题需要分两种情况来解说: 1.当变量i的数据类型是c++语言默认提供的类型的话,他们的效率是一样的. int a,i=0;     a=++i;汇编代码如下: int a,i=0; 01221A ...

  7. linux下笔记本有线网卡"未受管理"

    前段时间因为在弄一个笔记双网卡共享上网的事情把笔记本的有线网卡弄环了,连接的时候一直出现如下情况: 1)有线网卡:未受管理 2)无线网卡:每次登录的时候必须把原来登录过的信息删除掉,然后重新输入密码, ...

  8. CDLinux环境下WiFi密码破解

    > 准备好所需软件以及上篇教程中使用Fbinstool制作的可启动U盘 2 > 解压CDLinux-0.9-spring-0412.iso到U盘的根目录  如图 3 > 打开fbin ...

  9. readv和writev函数

    readv 和 writev 函数用于在一次函数调用中读.写多个非连续缓冲区.有时也将这两个函数称为散布读和聚集写. #include <sys/uio.h> ssize_t readv( ...

  10. hadoop权威指南 chapter1 Meet Hadoop

    Meet Hadoop 1.1 Data!(数据) Most of the data is locked up in the largest web properties (like search e ...