2013年6月6日

Python 正则表达式 引入变量

摘要: 正则表达式可以用拼接形式 (r' ' + str(i) + ' ') 来引入变量ipython hello.py fileopen.tgff 2找到fileopen.tgff 中符合 From t0_(\S*) TO t0_(\S*) 和 From t1_(\S*) TO t1_(\S*) 形式并提取group(1)和(2)分别写入文件t0.csv和t1.csv。#!/usr/bin/python#argv[1] is a filename; argv[2] is the number of graphimport re,sys,stringfp = open( 阅读全文
posted @ 2013-06-06 10:29 Samuel Yang 阅读(6853) 评论(0) 推荐(0) 编辑
2012年3月22日

单层感知器 逻辑“或”运算学习算法 Matlab

摘要: X=[1,0,0;1,0,1;1,1,0;1,1,1];W=[0.5,0.5,0.5];d=[-1,1,1,1];r=0.9;for n=1:1:1000 m=W(n,1)+W(n,2)*X(mod(n-1,4)+1,2)+W(n,3)*X(mod(n-1,4)+1,3); if(m<0) y=-1; else y=1; end WW=W(n,:)+r*(d(mod(n-1,4)+1)-y)*X(mod(n-1,4)+1,:); WW=WW'; W=W'; W=[W,WW]; W=W';endplot(0,0,'... 阅读全文
posted @ 2012-03-22 21:02 Samuel Yang 阅读(1167) 评论(0) 推荐(0) 编辑
2012年3月5日

2.5 单层感知器 逻辑“或”运算学习算法C++程序

摘要: 学习算法如下:1.设置变量和参量:X(n)=[1,x1(n),x2(n),...,xm(n)]T,为输入向量,或称训练样本。W(n)=[b(n),w1(n),w2(n),...,wm(n)]T,为权值向量。…………见人工神经网络原理及仿真实例 第2版 高隽 25页。#include<iostream>using namespace std;#define N 100 //迭代次数int main(){ long i,x[4][3]={{1,0,0},{1,0,1},{1,1,0},{1,1,1}}; double w[N][3],m,y,r=0.8,d[4]={0,1,1,1};/ 阅读全文
posted @ 2012-03-05 22:14 Samuel Yang 阅读(933) 评论(0) 推荐(0) 编辑
2012年2月21日

1.2.7 IBM Minus One 43.37%(504,1162)

摘要: Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1162 Accepted Submission(s): 504Problem DescriptionYou may have heard of the book '2001 - A Space Odyssey' by Arthur C. Clarke, or the film of the same name by Stanley Kubrick. In it a spaces 阅读全文
posted @ 2012-02-21 10:45 Samuel Yang 阅读(207) 评论(0) 推荐(0) 编辑
2012年2月20日

模糊信息处理作业——统计隶属函数

摘要: membership.mfunction [man]=membership(database)[row,column]=size(database);mi=database(1,2);ma=database(1,3);for i=2:row t=database(i,2); if(mi>t) mi=t; end t=database(i,3); if(ma<t) ma=t; endendlong=ma-mi+1;man(:,1)=linspace(mi,ma,long);man(:,2)=[0];for i=1:long for j=1:row ... 阅读全文
posted @ 2012-02-20 09:59 Samuel Yang 阅读(212) 评论(0) 推荐(0) 编辑

模糊信息处理作业——生成模糊控制表

摘要: View Code #include<iostream>#include<iomanip>#include<stdio.h>using namespace std;//PB,PS,Z,NS,NB分别为0,1,2,3,4double minu(double a,double b){ if(a<b) return a; else return b;}int main(){ double e[5][9]={ {0,0,0,0,0,0,0,0.5,1}, {0,0,0,0,0,0.5,1,0.5,0}, {0,0,... 阅读全文
posted @ 2012-02-20 09:36 Samuel Yang 阅读(391) 评论(0) 推荐(0) 编辑
2012年2月19日

1.2.5 decimal system 40.03%(492,1229)

摘要: Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1229 Accepted Submission(s): 492Problem DescriptionAs we know , we always use the decimal system in our common life, even using the computer. If we want to calculate the value that 3 plus 9, we just 阅读全文
posted @ 2012-02-19 19:42 Samuel Yang 阅读(233) 评论(0) 推荐(0) 编辑

1.2.6 GPA 41.30%(477,1155)

摘要: Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1155 Accepted Submission(s): 477Problem DescriptionEach course grade is one of the following five letters: A, B, C, D, and F. (Note that there is no grade E.) The grade A indicates superior achieveme 阅读全文
posted @ 2012-02-19 19:42 Samuel Yang 阅读(200) 评论(0) 推荐(0) 编辑

1.2.3 Buildings 76.38%(582,762)

摘要: Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 762 Accepted Submission(s): 582Problem DescriptionWe divide the HZNU Campus into N*M grids. As you can see from the picture below, the green grids represent the buidings. Given the size of the HZNU C 阅读全文
posted @ 2012-02-19 15:47 Samuel Yang 阅读(201) 评论(0) 推荐(0) 编辑
2012年2月18日

1.2.2 Rightmost Digit 28.63%(576,2012)

摘要: Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2012 Accepted Submission(s): 576Problem DescriptionGiven a positive integer N, you should output the most right digit of N^N.InputThe input contains several test cases. The first line of the input is 阅读全文
posted @ 2012-02-18 23:07 Samuel Yang 阅读(133) 评论(0) 推荐(0) 编辑