Skip to content

Instantly share code, notes, and snippets.

@takoika
takoika / baibai.go
Last active February 26, 2016 02:58
バイバイマンを数えよう(https://codeiq.jp/q/2593). Python2(51), Python3(52), Go(127), Scala(96).
package main
import "fmt";func main(){a:=[200]uint64{1,1,1,1,2}
for i:=0;i<100;i++{fmt.Println(a[i])
a[i+5]=a[i]+2*a[i+1])}}
@takoika
takoika / .block
Last active February 15, 2016 13:52
Qiita tag visualization.
scrolling: yes
height: 800
@takoika
takoika / qiitaCrowl.py
Created February 13, 2016 06:00
Qiita api wrapper for crowling for limited purpose.
import time
import urllib
import urllib.parse
import urllib.request
import json
sleep_time = 4 # Sleep time 4 seconds is determined for fear of exceeding request limits. 1request/4sec < 1000request/1hour
api_url = "http://qiita.com/api/v2/"
def getQiita(bearer_token,data_obj,protocol):
@takoika
takoika / dice2_sample.py
Created January 25, 2016 07:27
Python code call dice2.stan with generating data.
!/usr/bin/env python
import pystan
import numpy
import random
import matplotlib.pyplot as plt
m = 6
N = 10000
@takoika
takoika / dice_sample.py
Created January 25, 2016 03:15
Sample code to call dice.stan with input data
#!/usr/bin/env python
import pystan
from numpy import random
import matplotlib.pyplot as plt
m = 6
N = 1000
prob = [1/float(m) for i in range(m)]
@takoika
takoika / m_dice2.stan
Last active January 25, 2016 07:22
Stan code for inferring probabilities of m-face dice from the number of occurrences of an outcome which is sum of two m-dice's outcomes.
data
{
int <lower=0> m; // The number of dice faces
int <lower=0, upper=N> x[2*m-1]; // The numbers of events. x[i] indeicates the number of occurences that a sum of two dices is i+1 in [2,...,2*m].
}
parameters
{
simplex[m] theta1; // Probability for each face.
simplex[m] theta2; // Probability for each face.
@takoika
takoika / m_dice.stan
Created January 22, 2016 15:08
Stan code for inferring probability of m-face dice.
data
{
int <lower=0> m; // The number of dice faces
int <lower=0> x[m]; // The numbers of events. x[i] indicates the number of occurence of i-th face.
}
parameters
{
simplex[m] theta; // Occurence probabilities.
}