2012-01-01から1年間の記事一覧

trianble.py

#-*- coding:utf - 8 #1-6 気軽にウォーミングアップ p21-22 #input #n = 5 #a = [2, 3, 4, 5, 10] n = 4 a = [4,5,10,20] def solve(): #answer ans = 0 #we do not choose choices with duplication for i in xrange(n): for j in xrange(i+1, n): for k i…

Model-based influences on humans' choices and stratal prediction errors(Daw, 2011)

Abstract: The mesostriatal dopamine system is prominently implicated in model-free reinforcement learning, with fMRI BOLD signals in ventral striatum notably covarying with model-free prediction errors. However, latent learning and devalua…

Game theory and neural basis of social decision making(Lee 2009)

Abstract: Decision making in a social group has two distinguishing features. First, humans and other animals routinely alter their behavior in response to changes in their physical and social environment. As a result, the outcomes of decis…

Project Euler76(python, 0.008590s)

#-*- coding:utf-8 -*- import numpy as np from datetime import datetime def Euler76(A, n): A[0][0] =1 for i in xrange(n): for j in xrange(i + 1): if j == 1: A[i,j] = 1 elif (i == j): A[i,j] = 1 else: A[i, j] = A[i-j, j] + A[i-1][j-1] return…

Euler 87(python: 1.019476s)

#-*- coding:utf-8 -*- from datetime import datetime import random import numpy as np #素数判定 def is_prime3(q,k=50): q = abs(q) if q == 2: return True if q < 2 or q&1 == 0: return False d = (q-1)>>1 while d&1 == 0: d >>= 1 for i in xrange…

Optimisation and Search in Chapter 11 (Machine Learning written by Stephen Marsland)

editing now.....I'm gonna introduce some methods for optimization problems..... Newton method Lenvenberg_marquard method Conjugate Gradient method #-*- coding:utf-8 -*- import numpy as np def Jacobian(x): return np.array([.4*x[0],2*x[1]]) …

The example of CVXOPT

Hi there!Today, I would like to introduce cvxopt to you. CVXOPT is a library for resolving convex optimization like linear programs, and it is written by Python.please be careful for other packages when you want to install this in Mac. bec…

Hodgkin-Huxley model

This is the famous model for simulating the action potential of a neuron.In terms of neuroscience, the mechanism of an action potential is explained as like this. (1)When a membrane receives a stimulus, stimulus-dependent Na+ channels open…

Leaky Integrate and Fire model

(When I go back to Tokyo, I would like to comment on this code.)This code is mostly copied from the end of this site.... Neurdon #-*- coding:utf-8 -*- from __future__ import division import numpy as np import matplotlib.pyplot as plt class…

Neural Modeling with Python(IF, HH, Izhikevich,Diffusional equation, cable theory etc....)

In this log, I am summarizing Neural Models' articles. Later, I would like to make gists of them with python codes.Spiking Neuron Models Single Neurons, Populations, Plasticity comments for modelsSTEPS: Modeling and Simulating Complex Reac…

Project Euler 89 (python, 0.04s)

#-*- coding:utf-8 -*- from datetime import datetime def smallest_num(n): counter = 0 num = n dict_num = {"0":0, "1":1, "2":2, "3":3, "4":2, "5":1, "6":2, "7":3, "8":4, "9":2} if n >= 1000: counter += num / 1000 num = num % 1000 for i, d in…

Project Euler 70(python, 1.776935s)

#-*- coding:utf-8 -*- import random from datetime import datetime #素数判定 def is_prime3(q,k=50): q = abs(q) if q == 2: return True if q < 2 or q&1 == 0: return False d = (q-1)>>1 while d&1 == 0: d >>= 1 for i in xrange(k): a = random.ran…

Project Euler 69(python 0.001357s)

解き方的な #-*- coding:utf-8 -*- import random from datetime import datetime #素数判定 def is_prime3(q,k=50): q = abs(q) if q == 2: return True if q < 2 or q&1 == 0: return False d = (q-1)>>1 while d&1 == 0: d >>= 1 for i in xrange(k): a =…

Project Euler 63 (python 0.000409s)

#-*- coding: utf-8 -*- from datetime import datetime def Euler63(): total = 0 for i in xrange(1,10): counter = 1 length = len(str(i ** counter)) while counter == length: total += 1 counter += 1 length = len(str(i ** counter)) return total …

Project Euler 92(python, 3minutes)....

完全に敗北です。 くそコードだけども、仕方ない。 999999 -> 567だと気づけばもっと早いコードがかける。 が、考慮しても30秒しな縮まらず敗北感。 #-*- coding:utf-8 -*- from datetime import datetime def square_count(x, List1, List2): count_squar…

自分用のプログラム

#-*- coding:utf-8 -*- import numpy as np import matplotlib.pyplot as plt def main(): count = 0 #counter delta_time = 0.001 #sec N = 10. # the number of firing per second DAp = 0.35e-6 #M the ititial value of the cons of DA Km = 4.98e-6 #M …

AOJ - Problem 0035 : Is it Convex?(C言語)

"問題35"交差判定の式を用いれば一発だったった。 #include <stdio.h> double intersection(double a, double b, double c,double d, double e,double f,double g,double h){ double tc, td; tc = (a - b) * (g - e) + (e - f) * (a - c); td = (a - b) * (h - e) + (</stdio.h>…

AOJ - Problem 0033 : Ball (C言語)

"問題0033"つまりは、BとCの一番上にある数よりも小さな数のボールがくれば、NOを出力すればいいだけ。 #include <stdio.h> int main(void){ int i, B, C,count, set, num[10]; scanf("%d", &set); for(i = 0; i < set; i++){ scanf("%d %d %d %d %d %d %d %d %d %d",</stdio.h>…

AOJ - Problem 0034 : Railway Lines(C言語)

"問題0034"結局は、二つの列車の速度の比率から交わるポイントが導出できる。 v1:v2 = 列車1が進んだ距離/(全体の線路の長さ) : 列車2が進んだ距離/(全体の線路の長さ) #include <stdio.h> int main(void){ int i; int num[12]; double total, rate, sum; while(scan</stdio.h>…

色彩語における立場

ソシュールによれば「言語は差異の体系」でした。そして、ここで明らかになるのは 「言語の自律性」です。なぜなら、「差異の体系」は記号そのものが持つ特性であり、 それは発話や聴覚のような器官によって根本的には影響されず、恣意性によって定義さ れる…

-差異の体系-

前章の最後の節において、ソシュールにおける言語学の2つの軸に関する指摘を確認しました。 特に、いままで説明してきたソシュール独自の言葉は、静的な言語学を改めて研究するための準備 だとも指摘しています。ここでは、前章の最後のところで指摘した『…

-シニフィアン、シニフィエ-

いままで言語の本質を「聴覚イメージと概念のつながり」という言葉で表現してきました。 しかしながら、聴覚イメージという言葉が発話という声に出して行う行為と混同しやすいもの に見えてしまわないでしょうか。また、発話と言語は独立したものだとソシュ…

-言語の2つの基本原理-

今回はソシュールの指摘する言語の2つの原理である恣意性と線状性 について説明します。 線状性と恣意性を簡単に表現すると次のようになります。 (1)恣意性ー聴覚イメージと概念は本来的に異なるもので無関係である ということ (2)線状性ー言語記号の…

-通時態、共時態-

今回は、ソシュールが示した言語学の新たな道について説明したいと思います。 ソシュールの行った重要な点として、その当時主流であった歴史言語学(比較言語学) 以外の言語学の対象を示したということが挙げられます。歴史言語学の目標は、元々は 一つであ…

-言語の本質-

発話は、言葉を言語システムと呼ぶべきものに基づいて行われる 行為であると定義されましたが、言語がまだどのようなものか 分かっていません。ソシュールが用いた次の図[1]を使って言語の 本質を改めて考えてみましょう。 図1の下の部分は、2人の人が会話…

-言語活動、言語、発話-

ソシュールは、言語学の特有の問題とそれ意外を区別するために、まず人間の 言語活動(ランガージュ)を発話(パロール)と言語(ラング)に分けます。 (詳述していませんが、)言語活動とは、スピーチや会話、手紙を書く行為、教科書を読んだり といった言…

ソシュールの言語学(言語学入門第一回)

[ソシュール] 今回は初回ですから、構造言語学の創始者と呼ばれるフェルディナン・ソシュール (1857-1913)を取り上げたいと思います。ソシュールは、スイスのジュネーブ生まれの 学者で、彼が「一般言語学講義」で示した考えは当時の言語学に決定な影響を与…

ラグランジュ補間とニュートン補間の実装

スプライン補間をやりたかったのですが、 まだできたラグランジュ補間とニュートン補間を行いました。 以下のサイトを参考にしました。 "補間法(ラグランジュ補間とスプライン補間)" 解説はまた今度(くるのか?) #-*- coding:utf-8 -*- #ラグランジュ補間 …

Project Euler 62(python 0.056737s)

方針: (1)立方数を文字列に直してリスト化し、ソートして文字列に戻す (2)(1)で得た文字列を辞書のキーにし、値を[同じ要素からなる立方数の数, 立方数]として指定する (3)同じ要素からなる立方数の数が5になれば終了立方数を分解し、ソート、そして合体させ…

Project Euler 7(Ruby 1.012031s)

require "benchmark" def is_prime(k) prime = [] total = [] for i in 0..k prime << 1 end q = Math.sqrt(k).to_i for i in 2..q if prime[i] == 1 for j in 2*i..k if j % i == 0 prime[j] = 0 end end end end for i in 2..k if prime[i] == 1 total << …