Skip to content

Instantly share code, notes, and snippets.

View chiral's full-sized avatar

Masayuki Isobe chiral

  • Adfive, Inc.
  • Taito-ku, Tokyo, Japan.
View GitHub Profile
@chiral
chiral / brand2.R
Created April 14, 2014 10:25
brand score estimation toy model with bayesian logistic regression
library(R2WinBUGS)
library(coda)
setwd("~/R")
eps <- 1.0E-4
N <- 10
K <- 2
data1 <- list(
@chiral
chiral / scw.R
Last active August 29, 2015 14:01
An implementation in R for "Exact Soft Confidence-Weighted Learning" ( http://icml.cc/2012/papers/86.pdf )
library("rjson")
scw <- function(D,eta,verbose=F) {
phi <- qnorm(eta)
psi <- 1+phi^2/2
zeta <- 1+phi^2
mu <- rep(0,D)
sigma <- diag(D)
@chiral
chiral / index.html
Created June 1, 2014 17:52
Mondorian art in Processing.js.
<html>
<body>
<script src="./processing.min.js"></script>
<canvas datasrc="./mondorian.pjs"></canvas>
</body>
</html>
@chiral
chiral / ApplesAndPears.java
Created June 5, 2014 03:05
SRM623Div2Hard in Java
import java.io.*;
import java.util.*;
public class ApplesAndPears {
private int[][][] sb;
public int getArea(String[] board, int K) {
int N = board.length;
sb = new int[3][N][N];
package
{
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.display.Bitmap;
import flash.text.StyleSheet;
import flash.text.TextField;
import flash.geom.Transform;
import flash.geom.Matrix;
import flash.events.*;
@chiral
chiral / input.csv
Last active September 5, 2015 12:55
marketing action optimization with binomial test and frontier curve
Ad Imp Clk
A 300 6
B 500 14
C 150 5
@chiral
chiral / iris.csv
Created September 5, 2015 14:08
simple 3 layer feed forward net for iris data by chainer
1 5.1 3.5 1.4 0.2 setosa
2 4.9 3 1.4 0.2 setosa
3 4.7 3.2 1.3 0.2 setosa
4 4.6 3.1 1.5 0.2 setosa
5 5 3.6 1.4 0.2 setosa
6 5.4 3.9 1.7 0.4 setosa
7 4.6 3.4 1.4 0.3 setosa
8 5 3.4 1.5 0.2 setosa
9 4.4 2.9 1.4 0.2 setosa
10 4.9 3.1 1.5 0.1 setosa
@chiral
chiral / lm_test.R
Created October 8, 2011 18:10
verification of PRML fig_1.5
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)
@chiral
chiral / CLT_test.R
Created October 8, 2011 18:58
simulation of CLT-theorem applied to unform distribution
# 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))
}
@chiral
chiral / get_twitter_json.pl
Created October 8, 2011 18:51
Twitter API sample
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);