Skip to content

Instantly share code, notes, and snippets.

@satomacoto
satomacoto / hello.md
Created March 1, 2013 16:40
Hello markdown

Hello

Hello

@satomacoto
satomacoto / mds_nihonseiji.py
Last active December 14, 2015 06:39
MDS to nihonseiji.com
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy
import scipy.spatial
# データ読み込み
f = open('nihonseiji.txt')
head = f.readline()
parties = head.strip().split('\t')[1:]
@satomacoto
satomacoto / dualscaling.py
Last active December 14, 2015 06:39
Dual scaling to nihonseiji.com
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy
# データ読み込み
f = open('nihonseiji.txt')
head = f.readline()
parties = head.strip().split('\t')[1:]
vlist = []
@satomacoto
satomacoto / baseball.py
Created February 23, 2013 02:40
Score simulation with batting averages
#!/usr/bin/env python
# -*- coding:utf-8 -*-
"""
# 打率列から得点のシミュレーション
- 9回
- 3アウトでチェンジ
- すべて単打
- 4回以上連続でヒットで得点
"""
@satomacoto
satomacoto / youtubelinks.rb
Created February 18, 2013 13:15
Get youtube links from a web site
@satomacoto
satomacoto / binary_tree_dp_dfs.py
Created February 13, 2013 07:31
Binary tree, DP, DFS
def binary_tree_dp_dfs(n, k=1, a=[1]):
'''
>>> for x in binary(3): print x
[1, 2, 4]
[1, 2, 5]
[1, 3, 6]
[1, 3, 7]
'''
if n == k:
yield a
@satomacoto
satomacoto / particles.html
Created December 11, 2012 03:31
D3 random particles
<html>
<head>
<title>
</title>
<script src="http://d3js.org/d3.v2.js"></script>
</head>
<body>
<script type="text/javascript">
@satomacoto
satomacoto / dsdr.py
Created December 10, 2012 04:54
[He 2012] Document Summarization based on Data Reconstruction
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy as np
class DSDR:
"""Z He, et al. Document Summarization based onData Reconstruction (2012)
http://www.aaai.org/ocs/index.php/AAAI/AAAI12/paper/viewPaper/4991
"""
@satomacoto
satomacoto / mathjax.html
Created November 29, 2012 06:15
MathJax Dynamic Math Test Page
<!DOCTYPE html>
<!-- http://docs.mathjax.org/en/v1.1-latest/typeset.html -->
<html>
<head>
<meta charset="utf-8">
<title>MathJax Dynamic Math Test Page</title>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {
inlineMath: [["$","$"],["\\(","\\)"]]
@satomacoto
satomacoto / tf.py
Created November 27, 2012 03:44
create a document-term frequency matrix
# create candidate sentense set
docs = [['a', 'b', 'c'],
['b', 'd']]
terms = ['a', 'b', 'c', 'd']
vlist = []
n = len(docs)
d = len(terms)
for doc in docs:
tmp = []
for term in doc: