Skip to content

Instantly share code, notes, and snippets.

satomacoto satomacoto

Block or report user

Report or block satomacoto

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View hello.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
if __name__ == '__main__':
print "Hello, world!"
@satomacoto
satomacoto / gist:1400302
Created Nov 28, 2011
A Blogger HTML/JavaScript gadget to add line number to gists, requires jQuery
View gist:1400302
<!-- add line number to gist -->
<script type="text/javascript">
$('.gist').each(function() {
$('.line',this).each(function(i, e) {
$(this).prepend(
$('<div/>').attr('unselectable','on').css({
'float' : 'left',
'width': '30px',
'font-weight' : 'bold',
'color': 'grey',
@satomacoto
satomacoto / lp.py
Created Dec 21, 2011
Linear Programming w/ OpenOpt, FuncDesigner, GLPK, CVXOPT
View lp.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from FuncDesigner import *
from openopt import LP
# 変数の定義
x1,x2 = oovars(2)
# 目的関数
f = 3*x1 + 2*x2
# 初期解
@satomacoto
satomacoto / gist:1521244
Created Dec 26, 2011
A Blogger HTML/JavaScript gadget to add line number to gists
View gist:1521244
<!-- add line number to gist -->
<script type="text/javascript">
var gists = document.getElementsByClassName('gist');
for (var i = 0; i < gists.length; i++) {
var lines = gists[i].getElementsByClassName('line');
for (var j = 0; j < lines.length; j++) {
var div = document.createElement('div');
div.innerHTML = j + 1;
div.style.cssFloat = 'left';
div.style.width = '30px';
@satomacoto
satomacoto / gist:1523083
Created Dec 27, 2011
LaTeX for Blogger, requires jQuery
View gist:1523083
<!--
LaTeX for Blogger, requires jQuery
1. Add a HTML/Javascript gadget in the Layout mode and write this code.
2. In the HTML edit mode, write equations as follows:
<div class="equation">
ax^2 + bx + c = 0
x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}
</div>
@satomacoto
satomacoto / mds.py
Created Jan 5, 2012
Multidimensional Scaling
View mds.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
多次元尺度構成法
Multidimensional Scaling; MDS
"""
import numpy as np
import matplotlib.pyplot as plt
@satomacoto
satomacoto / kpca.data
Created Jan 5, 2012
Kernel principal component analysis
View kpca.data
6.040760282116731938e-02 2.003600989193874138e-01 0
-2.180560612167562751e-01 -8.292820699779238636e-01 0
-5.144639589460509033e-01 8.281746425448210935e-01 0
-4.740161490764375866e-03 -3.159114014274040476e-03 0
-1.417081236535422117e-01 -1.966777129492919621e-02 0
6.803427539200110341e-02 7.803962205781220240e-02 0
-1.875352326510989487e-01 2.345321639090314769e-01 0
2.805120457198624351e-01 1.557595199768933847e-01 0
-2.649491374332632043e-01 -3.705041702348287058e-02 0
-1.841101081351155799e-01 -6.072910303536597360e-02 0
@satomacoto
satomacoto / hira.py
Created Jan 7, 2012
Extracts rubies of Aozora Bunko
View hira.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
regex = u'^[ぁ-ゞ・ー]+$' # ひらがな+・+ーだけ
p = re.compile(regex)
for line in open('ruby.txt'):
file, kanji, yomi = line.strip().split('\t')
View lda.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys,getopt
from numpy import array,matrix,diag
from scipy import sum,log,exp,mean,dot,ones,zeros
from scipy.special import polygamma
from scipy.linalg import norm
from random import random
View plsa.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import math
import random
class plsa():
def __init__(self,n,nz=2):
You can’t perform that action at this time.