2010-01-01から1年間の記事一覧

ネットワークのランダム化

ネットワークのランダム化1 #include<stdio.h> #include<math.h> #include<set> #include<map> #include<vector> #include<sstream> #include<fstream> #include<iostream> #include<string.h> #include<stdlib.h> #include<mt.h> int f_label(int i){ return (int)log2((double)i); } int main(){ using namespace std; FILE *fp; std:…</mt.h></stdlib.h></string.h></iostream></fstream></sstream></vector></map></set></math.h></stdio.h>

gslで離散一様分布乱数発生。

C gsl

gslで離散一様分布乱数発生。 http://www.gnu.org/software/gsl/manual/html_node/Sampling-from-a-random-number-generator.html

gslを用いたC言語のランダムシャッフル

gslを用いたC言語のランダムシャッフル。 http://www.gnu.org/software/gsl/manual/html_node/Shuffling-and-Sampling.html #include<stdio.h> #include<gsl/gsl_rng.h> #include<gsl/gsl_randist.h> int main(){ const gsl_rng_type *T; int a[42]; int i; gsl_rng *r; T=gsl_rng_default; r=gsl_rng_al</gsl/gsl_randist.h></gsl/gsl_rng.h></stdio.h>…

遺跡

万蔵寺廻り遺跡から産出された種実について点数の対数をX軸におき、産出した建物数をY軸に置いた散布図を描く。数の多い種類ほどより多くの家にある。それが対数的。 http://blog.livedoor.jp/archaeoring/archives/52102745.html 黒曜石の出土率と原産地か…

Rで2次元ヒストグラム3

R

2次元ヒストグラム3 hist2db<-function(x,y,kugirix,kugiriy){ sx<-kugirix[1:(length(kugirix)-1)] sy<-kugiriy[1:(length(kugiriy)-1)] fx<-kugirix[2:(length(kugirix))] fy<-kugiriy[2:(length(kugiriy))] boxf<-function(x){ j1<-max(which(sx

アニールネットワーク

アニールネットワーク #include<stdio.h> #include<math.h> #include<set> #include<map> #include<vector> #include<sstream> #include<fstream> #include<iostream> #include<string.h> #include<stdlib.h> int main(){ using namespace std; FILE *fp; std::string index; std::string str; std::string str2; std::map</stdlib.h></string.h></iostream></fstream></sstream></vector></map></set></math.h></stdio.h>

C++でネットワークの次数を求める

C++でネットワークの次数を求める test.net 1 3 2 3 4 5 2 1 #include<stdio.h> #include<iostream> #include<map> #include<string> #include<fstream> #include<vector> #include<set> int main(){ using namespace std; FILE *fp; std::string index; std::string value; std::string str; string str2; std::vec</set></vector></fstream></string></map></iostream></stdio.h>…

C++でスペース区切りのデータを連想配列に詰め込む

test.dat 1 2 1 3 1 5 3 5 2 4 #include<stdio.h> #include<iostream> #include<map> #include<string> #include<fstream> int main(){ using namespace std; FILE *fp; std::string index; std::string value; std::string str; char* str2; std::map<std::string,std::string> data; std::ifstream ifs("test.dat"); whil…</std::string,std::string></fstream></string></map></iostream></stdio.h>

c言語でカンマ区切りの文章を読む

c言語でカンマ区切りの文章を読む http://simd.jugem.jp/?eid=49 http://networkprogramming.blog18.fc2.com/blog-entry-89.htmlstrtok関数で空白で分ける。 strtok関数は、 strtok(文字列,区切り文字)の仕様。 一回目はstrok(文字列, 区切り文字)で呼ぶ。 …

C++言語で連想配列風。

C++言語で連想配列風。 map型を使って楽する。 #include <stdio.h> #include <string> #include <map> #include <iostream> int main(){ using namespace std; std::map<std::string,std::string> data; data["a"]="AA"; data["b"]="BB"; data["d"]="CC"; data["e"]="EE"; cout << data["d"] <<"\n"; return 0; }</std::string,std::string></iostream></map></string></stdio.h>

有向きコンフィグレーションモデル

有向きコンフィグレーションモデル import networkx as nx import random as ran #in1=[3,3,3,3,3] #out1=[3,3,3,3,3] def f(x): return int(ran.random()**(-1.0/3.0)) in1=map(f,range(10000)); out1=[] out1[:]=in1[:]; G=nx.directed_configuration_mode…

「あしたのジョーの 、あの時代」

25才定年。http://blog.goo.ne.jp/tuyu223/e/1c8f5671e3ca6be09fe21f4efdad77d0より引用 先日、NHKのETV特集で「団塊の世代とあしたのジョー」なる番組をやっていた。学生闘争の頃、男女関係なく戦いに明け暮れていたが、高度経済成長の波に飲まれ、結…

gslを使った一般の確率分布に従う離散分布の発生

c

GSLを使った一般の確率分布に離散分布の乱数発生(一般離散分布)。これで片付けないとメモリーがいっぱいになる void gsl_ran_discrete_free (gsl_ran_discrete_t * t); #include<stdio.h> #include<gsl/gsl_rng.h> #include<gsl/gsl_randist.h> int main(void){ double p[3]; int i; const gsl_rng_typ</gsl/gsl_randist.h></gsl/gsl_rng.h></stdio.h>…

Rのヒストグラムをより細かく制御(カーネル法)

R

カーネル法を細かく制御してRのヒストグラムを滑らかに書く。 Rのデフォルトのdensity関数もあるが細かく制御できないので以下の関数を使う。 pdf123<-function(d,p1,d1){ j<-0 for(i in 1:length(p1)){ j[i]<-length(d[abs(d-p1[i])<=d1[i] ]) } data.fra…

igoreの簡単な説明

igore の簡単な説明。 http://nps.sakura.ne.jp/sf/Igor/Igor1.htm マクロ window->produre を参考にコピペ。それをtextfileに保存。改編。igore コマンド duplicate A B //wave Aをwave Bにコピー KillWaves A // wave A を削除

無向グラフからループの取り出し

無向グラフからループの取り出し import networkx as nx G=nx.read_edgelist("test.net",create_using=nx.Graph()) j=nx.cycle_basis(G,'1') print j test.net 1 2 2 3 3 1 1 5 5 4 4 1 1 6

python で有向ネットワークの三角形の取り出し。

python で有向ネットワークの三角形の取り出し。test.net 1 2 2 3 3 1 1 5 5 1 import networkx as nx G=nx.read_edgelist("test.net",create_using=nx.DiGraph()); for i in G.nodes(): outs=G.successors(i); ins=G.predecessors(i); for j in outs: for k…

 構造体と構造体ポインタ

構造体でのキューの例。 (1)構造体の定義 (2)構造体宣言 (3)構造体ポインタ宣言 (4)アドレスを渡す。 (5)使うという順番。 struct node{ double value; struct node *next; }; int main(){ struct node fist; struct node *nodeA nodeA=&fist…

Rで2次元ヒストグラム2

R

hist2db<-function(x,y,kugirix,kugiriy){ sx<-kugirix[1:(length(kugirix)-1)] sy<-kugiriy[1:(length(kugiriy)-1)] fx<-kugirix[2:(length(kugirix))] fy<-kugiriy[2:(length(kugiriy))] boxf<-function(x){ j1<-max(which(sx

Rで2次元ヒストグラム

Rで2次元ヒストグラムを書く。 hist2db<-function(x,y,kugirix,kugiriy){ sx<-kugirix[1:(length(kugirix)-1)] sy<-kugiriy[1:(length(kugiriy)-1)] fx<-kugirix[2:(length(kugirix))] fy<-kugiriy[2:(length(kugiriy))] counts<-0 i1<-0 i2<-0 j1<-0 j2<-0 …

 メモ

なんか史料になる昔の人の日記みたい。 「景気低迷で日本は失われた世代の若者の国になりつつある。」 By CHARLES HUGH SMITH http://econdays.net/?p=702

python で強連結成分分解

ライブラリnetworkxを使うと簡単。 import networkx as nx G=nx.read_edgelist("test.net",create_using=nx.DiGraph()) j=nx.strongle_connected_components(G) l=0 for i in j: for k in i: print k,l; l=l+1; 最大強連結成分の抜き出し。 import networkx …

gsl で乱数発生

C

http://mine-weblog.blogspot.com/2009/05/gsl.html http://www.gnu.org/software/gsl/manual/html_node/Random-Number-Distribution-Examples.html #include <stdio.h> #include <gsl/gsl_rng.h> #include <gsl/gsl_randist.h> int main(){ const gsl_rng_type *T; //乱数生成器のタイプ gsl_rng *r; gs</gsl/gsl_randist.h></gsl/gsl_rng.h></stdio.h>…

ubuntu で wake on LAN の設定。

wake on Lan を設定しておくと、 遠隔地からLan経由で電源を入れられるようになる。 いざ、遠隔作業中に電源が切れた時に便利。 $ sudo apt-get install ethtool $ sudo ethtool -s eth0 wol g これで、遠隔地からwake on Lun のクライアントソフト等(vector…

boostでネットワーク解析

boostの導入は前の記事。 adjacency_list クラスは隣接行列をグラフ。Graph型として名付け直す。 色々なコンストラクタがある。 http://boost.cppll.jp/HEAD/libs/graph/doc/adjacency_list.html#sec:iterator-constructor 参考: パラメータは5つ。 EdgeLis…

boost

C

boost はC言語のライブラリ。インストール: cygwinで使う場合は、setup.exe (cygwinのインストール時に 使うソフト)からインストールできる。 テストプログラム (test.cpp) #include <iostream> #include <boost/format.hpp> using namespace std; int main(){ cout << boost::format(</boost/format.hpp></iostream>…

cygwinの最大メモリーの変更

cygwinは384MB以上のメモリーをデフォルトでは確保できない。 cygwinの最大メモリーの変更。レジストリを間接的にいじるので注意(1024Mb)。 regtool -i set /HKLM/Software/Cygnus\ Solutions/Cygwin/heap_chunk_in_mb 1024 regtool -v list /HKLM/Softwar…

python のnetworkx で複雑ネットワーク解析(これはかなり便利です)。

python のnetworkx で複雑ネットワーク解析。 networkxはpythonのグラフライブラリ。とてもよくできている。 各ノード間の経路長も関数一つ。ものすごく便利。。 ほとんどプログラム書かずRっぽく、インタラクティブで ネットワーク解析ができてしまう感じ…

分子生物学メモ(転写制御)について。

分子生物学メモ(転写制御)について。 メモです。間違っているかもしれません。 下から上に文章がつながっています。 (つづき)このメチル化の違いは、筋肉と肌など部位によっても違う、そのため体細胞クローンやIPS細胞を作る場合、このメチル化を受精…

windows7 (vista) で ssh

windows7 でcygwin を使ったsshXPとの違い。 (1)右クリック→管理者で実行(最大のはまりポイント)。 (2)windowsアカウントをcygwinに反映させること。 (3)userの追加は、sshd-user-config (4)必ず再起動 http://www.kawaz.jp/pukiwiki/?Cygwinhttp…