<?xml version="1.0" encoding="UTF-8" ?><rdf:RDF 
  xmlns="http://purl.org/rss/1.0/"
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:atom="http://www.w3.org/2005/Atom"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xml:lang="ja">
  <channel rdf:about="http://w.atwiki.jp/fun-sci/">
    <title>fun-sci @ ウィキ</title>
    <link>http://w.atwiki.jp/fun-sci/</link>
    <atom:link href="https://w.atwiki.jp/fun-sci/rss10.xml" rel="self" type="application/rss+xml" />
    <atom:link rel="hub" href="https://pubsubhubbub.appspot.com" />
    <description>fun-sci @ ウィキ</description>

    <dc:language>ja</dc:language>
    <dc:date>2007-05-27T21:15:44+09:00</dc:date>
    <utime>1180268144</utime>

    <items>
      <rdf:Seq>
                <rdf:li rdf:resource="https://w.atwiki.jp/fun-sci/pages/26.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/fun-sci/pages/25.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/fun-sci/pages/24.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/fun-sci/pages/23.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/fun-sci/pages/22.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/fun-sci/pages/21.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/fun-sci/pages/20.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/fun-sci/pages/19.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/fun-sci/pages/18.html" />
                <rdf:li rdf:resource="https://w.atwiki.jp/fun-sci/pages/17.html" />
              </rdf:Seq>
    </items>
	
		
    
  </channel>
    <item rdf:about="https://w.atwiki.jp/fun-sci/pages/26.html">
    <title>SASってさ</title>
    <link>https://w.atwiki.jp/fun-sci/pages/26.html</link>
    <description>
      SASを使うユーザーがどれくらいいるのか
実際のところどうなのか聞いて見たい人は多いのではないだろうか？

自分は、SASにはいろいろな疑問を持っている。
どっちかというと、クライアントで作業をすることの多い自分なので
サーバーベースで大規模システムにあわせているであろうSASに
どうしても窮屈を感じてしまうのです。


・今更、なんでラインベースのデータ更新なの？
と、思ってしまうのですよ。ファイル読み込みとか、大規模計算ならとにかく
何でもかんでもラインベースの仕組みで処理させるのはいただけない。
arrayなんか作っても、所詮作りこまれた配列システムにはかないません。

・なんでサブルーチンを作らせないの？
とにかく、データステップに関数を作らせてくださいという感じです。
今更、マクロとかLINKとかの制御ジャンプ構文だけ（しかもネスト制限あり）
というのはどうかと。

・IOMの仕様
サポートページがわかりづらいうえに、SAS IOMに渡すSASコードが純粋なコードでないと
動かない（らしい）というのはいただけない。ファイルでコードを開いて
直接投げ込むようなコードを書きたいときは、いろいろ前処理が必要で
リファクタリングしにくいと思う。    </description>
    <dc:date>2007-05-27T21:15:44+09:00</dc:date>
    <utime>1180268144</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/fun-sci/pages/25.html">
    <title>Rのオブジェクトでsummaryできない！</title>
    <link>https://w.atwiki.jp/fun-sci/pages/25.html</link>
    <description>
      そうそう、RobjをPython側でリスト、辞書で受け取ると
Rpyがうまく変換してくれないと、正しく実行してくれない。

特に、R特有のクラスである場合は困ってしまう。悩みます。

たとえば、
http://www21.atwiki.jp/fun-sci/pages/23.html
で出力される&quot;ret&quot;データは
r.summary(ret)としても、数値入り辞書と解釈されて

 [[&#039;  3&#039;, &#039;-none-&#039;, &#039;numeric&#039;], [&#039; 11&#039;, &#039;-none-&#039;, &#039;list&#039;], [&#039;  1&#039;, &#039;-none-&#039;, &#039;num
 eric&#039;], [&#039;100&#039;, &#039;-none-&#039;, &#039;numeric&#039;], [&#039;  3&#039;, &#039;-none-&#039;, &#039;call&#039;], [&#039;100&#039;, &#039;-none-
 &#039;, &#039;numeric&#039;], [&#039;  1&#039;, &#039;-none-&#039;, &#039;logical&#039;], [&#039;  3&#039;, &#039;formula&#039;, &#039;call&#039;], [&#039;  1&#039;,
  &#039;-none-&#039;, &#039;logical&#039;], [&#039;  1&#039;, &#039;-none-&#039;, &#039;character&#039;], [&#039;  3&#039;, &#039;terms&#039;, &#039;call&#039;],
  [&#039;  0&#039;, &#039;-none-&#039;, &#039;NULL&#039;], [&#039;  3&#039;, &#039;-none-&#039;, &#039;list&#039;], [&#039;  4&#039;, &#039;-none-&#039;, &#039;numeri
 c&#039;], [&#039;  0&#039;, &#039;-none-&#039;, &#039;NULL&#039;], [&#039;  0&#039;, &#039;-none-&#039;, &#039;NULL&#039;], [&#039;  4&#039;, &#039;-none-&#039;, &#039;li
 st&#039;], [&#039;  1&#039;, &#039;-none-&#039;, &#039;numeric&#039;], [&#039;100&#039;, &#039;-none-&#039;, &#039;numeric&#039;], [&#039;  1&#039;, &#039;-none
 -&#039;, &#039;numeric&#039;], [&#039;  5&#039;, &#039;-none-&#039;, &#039;list&#039;], [&#039;  3&#039;, &#039;-none-&#039;, &#039;numeric&#039;], [&#039;  1&#039;,
  &#039;-none-&#039;, &#039;numeric&#039;], [&#039;  1&#039;, &#039;-none-&#039;, &#039;numeric&#039;], [&#039;  1&#039;, &#039;-none-&#039;, &#039;numeric&#039;
 ], [&#039;100&#039;, &#039;-none-&#039;, &#039;numeric&#039;], [&#039;100&#039;, &#039;-none-&#039;,    </description>
    <dc:date>2007-05-27T20:45:35+09:00</dc:date>
    <utime>1180266335</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/fun-sci/pages/24.html">
    <title>S-Plusによる統計解析のデータをPythonへ</title>
    <link>https://w.atwiki.jp/fun-sci/pages/24.html</link>
    <description>
      ＊S-Plusによる統計解析のデータをPythonへ

RはS-Plusのクローンなので
「S-Plusによる統計解析」を参考にしている人が多いのでは？
この本に書いてあるデータはlibraryとして提供されているので
勉強するのに使いやすい。
せっかくなので、Pythonでも利用してみたいなんてときは
こんな感じでデータの抽出、ファイルへの書き出しができます。

 from rpy import *
 
 r(&quot;library(MASS)&quot;)
 dat = []
 # データをリスト中に取り込む
 dat = r(&quot;Aids2&quot;)
 
 # ファイルへの書き込み
 myf = open(&quot;Aids2.txt&quot;,&quot;w&quot;)
 myf.write(str(dat))
 myf.close()    </description>
    <dc:date>2007-05-24T00:16:48+09:00</dc:date>
    <utime>1179933408</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/fun-sci/pages/23.html">
    <title>rpy glm覚え書き</title>
    <link>https://w.atwiki.jp/fun-sci/pages/23.html</link>
    <description>
      テストデータでscipy、rpyのglmの使い方を勉強してみる。

出展はハーバード大学講義テキスト
生物統計学入門のChapter 19
データは公開されているものなのでOKかと

コードはこんな感じ

 from scipy import *
 from rpy import *
 import csv
 
 # low_infants.txtは下の「データ」のテキストファイル
 rd1 = csv.reader(file(&quot;low_infants.txt&quot;)) 
 
 low_inf = []
 
 for line in rd1:
   low_inf.append(line)
 
 # この時点では文字列のarray
 low_infa = array(low_inf)
 
 # 文字列を64精度の数値に変換
 low_infa = low_infa.astype(float64)
 
 x1=low_infa[:,4].tolist()
 x2=low_infa[:,2].tolist()
 y=low_inf[:,1].tolist()
 
 ret = r.glm(r(&quot;y~x1+x2&quot;),data=r.data_frame(x1=x1,x2=x2,y=y,family=&#039;gaussian&#039;))
 
 ret[&#039;coefficients&#039;]

係数は本に載っていたように出てきた。
一応、うまく行ってる？



＊＊　データ
 27,41,29,1360,37,0
 29,40,31,1490,34,0
 30,38,33,1490,32,0
 28,38,31,1180,37,0
 29,38,30,1200,29,1
 23,32,25,680,19,0
 22,33,27,620,20,1
 26,38,29,1060,25,0
 27,30,28,1320,27,0
 25,34,29,830,32,1
 23,32,26,880,26,0
 26,39,30,1130,29,0
 27,38,29,1140,24,0
 27,39,29,1350,26,0
 26,37,29,950,25,0
 27,39,29,1220,25,0    </description>
    <dc:date>2007-05-24T23:48:20+09:00</dc:date>
    <utime>1180018100</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/fun-sci/pages/22.html">
    <title>R関連</title>
    <link>https://w.atwiki.jp/fun-sci/pages/22.html</link>
    <description>
      ＊＊R関連（といいつつrpyばっか）

-[[rpyとgnuplot覚え書き&gt;http://www21.atwiki.jp/fun-sci/pages/21.html]]

-[[rpy glm覚え書き&gt;http://www21.atwiki.jp/fun-sci/pages/23.html]]

-[[「S-Plusによる統計解析」のデータをPythonへ&gt;http://www21.atwiki.jp/fun-sci/pages/24.html]]

-[[Rのオブジェクトでsummaryできない！&gt;http://www21.atwiki.jp/fun-sci/pages/25.html]]    </description>
    <dc:date>2007-05-27T20:48:47+09:00</dc:date>
    <utime>1180266527</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/fun-sci/pages/21.html">
    <title>rpyとgnuplot覚え書き</title>
    <link>https://w.atwiki.jp/fun-sci/pages/21.html</link>
    <description>
      Rpyを使ってRに線形回帰（単なる直線回帰ですが）を
させる方法を説明しているページ

http://www2.warwick.ac.uk/fac/sci/moac/currentstudents/peter_cock/python/lin_reg/

のplot部分をGnuplot.pyを使ってGnuplotで書いてみる。

 from rpy import r
 
 import Gnuplot
 
 my_x = [5.05, 6.75, 3.21, 2.66]
 my_y = [1.65, 26.5, -5.93, 7.96]
 ls_fit = r.lsfit(my_x,my_y)
 gradient = ls_fit[&#039;coefficients&#039;][&#039;X&#039;]
 yintercept= ls_fit[&#039;coefficients&#039;][&#039;Intercept&#039;]
 
 #ここから
 
 g1 = Gnuplot.Gnuplot()
 g1.plot(zip(mx_x,my_y))
 
 # sに直線の式のTemplateを作成
 s = Template(&#039;$grad * x + ($itspt)&#039;)
 form1 = s.substitute(grad=gradiant,itspt=yintercept)
 &#039;5.3935773612 * x + (-16.2811279931)&#039;
 
 g1.plot(form1)    </description>
    <dc:date>2007-05-21T22:26:17+09:00</dc:date>
    <utime>1179753977</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/fun-sci/pages/20.html">
    <title>更新ですよ</title>
    <link>https://w.atwiki.jp/fun-sci/pages/20.html</link>
    <description>
      フォルダ監視をする必要があるときは
大抵、time?かなにかで時限式に
ls -la をgrepして判定するんですが
これができるのはUNIX系だけです。
WINDOWSは調べるのめんどそお
で、Pythonで組んでみる

簡単なやつでファイル構成が変わるか
最終更新日が変わったかで見るものです。

 import os,sys,time,pprint
 from stat import *
 
 
 class touched:
 　　def watching(self,dirpath):
 　　　　
 　　　　dir1 = self.dirstat(dirpath)
 　　　　
 　　　　while 1:
 　　　　　　
 　　　　　　time.sleep(5)
 　　　　
 　　　　　　try:
 　　　　　　　　dir2 = self.dirstat(dirpath)
 　　　　　　　　self.checkdirf(dir1,dir2)
 　　　　　　　　self.checkdirs(dir1,dir2)
 　　　　　　　　print &quot;next ... &quot;
 　　　　　　except Exception,e:
 　　　　　　　　print e
 　　　　　　　　
 　　　　　　dir1 = dir2[:]
 　　　　
 　　def checkdirf(self,dir1,dir2):
 　　　　
 　　　　if dir1[0] != dir2[0]:
 　　　　　　raise Exception(&quot;FILE_DIFF&quot;)
 　　　　
 　　def checkdirs(self,dir1,dir2):
 　　　　
 　　　　if len(dir1[0]) == 0 or len(dir2[0]) == 0:
 　　　　　　raise Exception(&quot;NO FILE&quot;)
 　　　　
 　　　　pp = pprint.PrettyPrinter(indent=4) 
 　　　　for i in range(0,len(dir1)):
 　　　　　　# pp.pprint(dir1[1])
 　　　　　　if dir1[1][i][ST_MTIME] != dir2[    </description>
    <dc:date>2007-01-16T00:32:14+09:00</dc:date>
    <utime>1168875134</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/fun-sci/pages/19.html">
    <title>ファイルとフォルダの検索と時刻</title>
    <link>https://w.atwiki.jp/fun-sci/pages/19.html</link>
    <description>
      ジェネレータos.walkで階層を総ざらいして
os.statでフォルダ情報を拾います。
基本的にコマンドで
dir /s | grep -E &quot;2006/12/17&quot;
とかの方が楽だし、速いのはしょうがない

 import time,os,sys,fnmatch
 from stat import *
 
 def watch_dir(dflt=&#039;.&#039;,patterns=&#039;*&#039;,yield_folders=False,single_level=False):
     
     patterns = patterns.split(&#039;;&#039;)
     
     for path,subdir,files in os.walk(dflt):
         if yield_folders:
             files.extend(subdir)
         files.sort()
         
         for name in files:
             for pattern in patterns:
                 if fnmatch.fnmatch(name,pattern):
                     yield os.path.join(path,name),os.stat(os.path.join(path,name))
                     break
         if single_level:
             break
         
 if __name__==&#039;__main__&#039;:
     for mypath,mystat in watch_dir(dflt=&quot;/&quot;,patterns=&quot;tex&quot;,yield_folders=True):
         print mypath + &quot; : &quot;  + time.ctime(mystat.st_atime)    </description>
    <dc:date>2006-12-17T09:45:45+09:00</dc:date>
    <utime>1166316345</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/fun-sci/pages/18.html">
    <title>pylab関連</title>
    <link>https://w.atwiki.jp/fun-sci/pages/18.html</link>
    <description>
      -[[matplotlibとthreadの相性&gt;http://www21.atwiki.jp/fun-sci/pages/17.html]]    </description>
    <dc:date>2006-12-12T00:21:38+09:00</dc:date>
    <utime>1165850498</utime>
  </item>
    <item rdf:about="https://w.atwiki.jp/fun-sci/pages/17.html">
    <title>matplotlibとthreadの相性</title>
    <link>https://w.atwiki.jp/fun-sci/pages/17.html</link>
    <description>
      なんとなくmatplotlibを複数の画面で表示したくなったので
ThreadPoolを作って、同じグラフを複数表示！と考えていたのですが

どうもmatplotlibはThreadSafeではないようです。

PGはPython Cook Bookのスレッドプールサンプルを使い、
下みたいな感じに修正。（さすがに全ソースはのせられない。。。）

 try:
 　　if　command　==　&#039;process&#039;:
 　　　　　　　　
 　　　　#result　=　&#039;new&#039;　+　item
 　　　　#mythread()内でsubplot()を呼ぶ
 　　　　result　=　mythread()　+　item
 　　　　　　　　　　　　
 　　else:
 　　　　　　raise　ValueError,&#039;Unknown command　%r&#039; % command
 except:
 　　　print　&#039;error　raised!&#039;
 　　　#report_error()
 　　　traceback.print_exc()

えーー、見事に止まってくださいました。
しょーがねーなーと思い、１回に１度だけ実行させるようにして
再度実行。

 Fatal Python error: PyEval_RestoreThread: NULL tstate
 
 This application has requested the Runtime to terminate it in an unusual way.
 Please contact the application&#039;s support team for more information.

むっきゃーーーーーー（のだめ風）

ってわけで、matplotlibは、１回に１度だけ、１プロセス上で使うことをおすすめ。
（って、適当に試しただけなので、しっかり改造すればできるかも）    </description>
    <dc:date>2006-12-12T00:19:01+09:00</dc:date>
    <utime>1165850341</utime>
  </item>
  </rdf:RDF>
