Skip to content

Instantly share code, notes, and snippets.

View piroyoung's full-sized avatar
🏠
Working from home

Hiroki Mizukami piroyoung

🏠
Working from home
View GitHub Profile
@piroyoung
piroyoung / norm.r
Created December 8, 2013 09:47
testgitst
#標本平均,普遍分散のヒストグラム
setwd("~/Desktop")
Num.repeat <- 1.0 * 10^5
List.flex <- c(2,3,4,5,6,7)
Tran <- "40"
List.color<- c("#0000ff","#3300cc","#660099","#990066","#cc0033","#ff0000")
Breaks <- 1000
@piroyoung
piroyoung / metropolis-hasting-method.r
Created December 23, 2013 13:07
MCMC visualization from sublime text
Sample <- c(4,3,4,7,7,
6,3,7,8,0,
1,7,8,6,7,
4,4,7,3,4)
n <- 8
Step <- 0.001
mcmcStep <- 20000
mcmcTimes <- 20
Z <- 1:mcmcStep
library(shiny)
# Define server logic required to generate and plot a random distribution
shinyServer(function(input, output) {
output$distPlot <- renderPlot({
N.sample <- input$obs
N.mean <- 5000
library(shiny)
# Define UI for application that plots random distributions
shinyUI(pageWithSidebar(
# Application title
headerPanel("Histgram of sample mean about dicerolling"),
# Sidebar with a slider input for number of observations
sidebarPanel(
@piroyoung
piroyoung / model.stan
Last active January 4, 2016 12:29
Model of Poison regression
data {
int<lower=0> N;
real x[N];
real f[N];
int<lower=0,upper=100> y[N];
}
parameters {
real b0;
real b1;
real b2;
@piroyoung
piroyoung / glm.R
Last active January 4, 2016 12:29
Sampling on rStan
library(rstan)
library(coda)
setwd("~/R/stan_pois")
dat <- read.csv("data3a.csv",header = TRUE)
dat$f <- as.numeric(dat$f) -1 #カテゴリカルを01に変換
listed.dat <- list(x = dat$x , y = dat$y, f = dat$f, N=100)
fit<-stan(file="model.stan",data=conflict.dat,iter=5000,chains=3)
traceplot(fit)
# encoding: UTF-8
require "fileutils"
###random sampling
class ProcessCSV
def initialize (orig)
#本当はコンストラクタで禁則文字,文字コードの設定もしたい.
@origFileName = orig
end
#!/usr/bin/ruby
#! ruby -EUTF-8
# -*- mode:ruby; coding:utf-8 -*-
require 'MeCab'
require 'open-uri'
require 'nokogiri'
# スクレイピングするURL
url = []
selector = []
@piroyoung
piroyoung / analyzeTweet.rb
Created February 17, 2014 13:55
showJapaneseTweet
#encoding : utf-8
require 'twitter'
require 'pp'
client = Twitter::Streaming::Client.new do |config|
config.consumer_key = '0CmP0LrH7vkuRweDR0ySKg'
config.consumer_secret = 'fEeMhJQSZVMsVRQcYkx8SLgQmZ5a6V14Thm4IU3l8A'
config.access_token = '147866733-qq35ey3FpaYWEUOdXjoyoj1iA9BlmiHDKNwzMX9Y'
config.access_token_secret = '93R4bQAPvND9A0ZPfbcHIVHLc0AUZcvrmHZR7Al376NEb'
@piroyoung
piroyoung / ggplot.r
Created March 2, 2014 15:36
plotting by ggplot
library(ggplot2)
library(reshape2)
setwd("~/work/R/ggplot2")
T <- 300
N <- 8
bm <- rnorm(T*N)
bm <- matrix(bm,nrow = T, ncol= N)
bm <- apply(bm, 2, cumsum)