This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sr <- function() source('lm_test.R') | |
make_data <- function(n,sd=0.4) { | |
x <- seq(0,2*pi,length=n) | |
y <- sin(x) + rnorm(n,0,sd) | |
return(data.frame(x=x,y=y)) | |
} | |
my_test <- function(d,m) { | |
z <- lm(y~poly(x,m),data=d) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use JSON; | |
use Encode; | |
if (@ARGV<1) { print "usage: $0 user_id [page]\n"; exit(0); } | |
my $url="http://twitter.com/statuses/user_timeline.json?id=$ARGV[0]"; | |
$url.="\\&page=$ARGV[1]" if ($ARGV[1]); | |
open(F,"wget $url -O -|");my $j=<F>;close(F); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# resulting image is | |
# http://dl.dropbox.com/u/15259519/images/CLT_sim.png | |
sr <- function() source("CLT_test.R") | |
sim1 <- function(n,m=500,c=30) { | |
mat <- matrix(runif(m*n),c(m,n)) | |
res <- (rowSums(mat)-n*0.5)/sqrt(n/12) | |
hist(res,nclass=c,main='',xlab=sprintf("N=%d, trial num=%d",n,m)) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package zk_queue; | |
use Net::ZooKeeper qw(:node_flags :acls); | |
sub die1 { | |
die("failed to create node: ".$_[0]."\n"); | |
} | |
sub die2 { | |
die("failed to delete node: ".$_[0]."\n"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# resulting image is | |
# http://dl.dropbox.com/u/15259519/images/hinomaru_NN.png | |
sr <- function() source("hinomaru_NN.R") | |
W <<- 300 | |
H <<- 200 | |
R <<- 60 | |
N <<- 6000 | |
E <<- 20 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ガウスカーネルのσパラメータの意味を調べるテスト | |
# examination of how sigma parameters in RBF kernel affect results. | |
# resulting image is, | |
# http://dl.dropbox.com/u/15259519/images/RBF_sigma.swf | |
sr <- function() source('RBF_sigma_test.R') | |
library(kernlab) | |
N <<- 100 | |
sigmas <<- c(0.0001,0.0005,0.001,0.005,0.01,0.05,0.1,0.5,1,5,10,50) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# YouTubeの動画のダイジェスト画像集を自動的に作成 | |
use GD; | |
use WWW::YouTube::Download; | |
use FFmpeg::Thumbnail; | |
use Statistics::R; | |
sub p { print STDERR $_[0]; } | |
my $video_id=shift or die "Usage: $0 video_id [ouput_dir] [skip] [threashold]"; | |
my $out_dir=shift or $out_dir='.'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use HTML::TreeBuilder; | |
our $alpha = 0.5; | |
our ($best,$best_rate); | |
our %special_alpha=('div',0.8,'span',1,'p',1,'a',0.1, | |
'ul',0.9,'ol',0.9,'li',0.9, | |
'style',0.1,'script',0.1,'noscript',0.1, | |
'b',1,'i',1,'h1',1,'h2',1,'h3',1,'font',1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use JSON; | |
use Encode; | |
#-------------------------------------------------- | |
sub pop1{pop@{$_[0]}} | |
sub pop2{$_=shift;(pop@$_,pop@$_)} | |
sub pop3{$_=shift;(pop@$_,pop@$_,pop@$_)} | |
sub popN{my($n,$_)=@_;map{pop@$_}(1..$n)} | |
sub popL{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"%<-%" <- function(x,y) call("<-",substitute(x),substitute(y)) | |
returm <- function(x) call("return",substitute(x)) | |
exec <- quote | |
join <- function(ss,sep) { | |
res <- "" | |
for (s in ss) { | |
res <- paste(res,s,sep=sep) | |
} | |
res |
OlderNewer