N armed bandit task

#n_armed_bandit.py # # n-armed bandit task chapter 2 Figure 2.1, 2.4 # # 1. implemented with softmax function or epsilon-greedy function # 2. implemented with online method for values # 3. implemented with optimistic comparison # import nu…

1D Heat Conduction with a delta function

Analytic solution #heat conduction with a delta function import numpy as np import matplotlib.pyplot as plt import time M = 100; #the number of division x = np.linspace(0, 1, M+1); N = 600; #finite series #T = [0.001, 0.004, 0.016, 0.064] …

Streamlines of A Free Vortex

We think a case of , .Then, when we think about velocity of this flow along x and y axis. Then we can get Figure1.However, when we think about inertial frame of reference. In this particular case, velocity is equivalent to this formula. [v…

C++ compiling with Mac terminal

gcc -c main.cpp gcc -o main.cgi main.o -lstdc++ ./main.cgi

Synaptic Conductance(alpha function, Python)

import math import numpy as np import matplotlib.pyplot as plt def trapsyn(dt, Tfin, gsyn): VCl = -68; #mV Cm = 1; #micro F/cm^2 gCl = 0.3; #mS/cm^2 z = 2./dt; Nt = int(math.ceil(1 + Tfin / dt)); #number of time steps V = np.zeros((Nt, 1))…

Implementation of quadratic integrate-and-fire model with Runge-Kutta method

[:large]Neurdon #-*- coding:utf-8 -*- import numpy as np import matplotlib.pyplot as plt #quadratic integrate and fire model class IzhNeuron: def __init__(self, label, a, b, c, d, v0, u0=None): self.label = label self.a = a; self.b = b sel…

Implementation of Fitzhug-Nagumo model with Runge-Kutta method

#-*- coding:utf-8 -*- import numpy as np import matplotlib.pylab as plt #node def phase_func(x, t, a=-1., b=0., c=0., d=-2.): return np.array([a*x[0]+b*x[1], c*x[0] + d*x[1]]) #focus def phase_focus(x, t, a=1., b=2., c=-2., d=1.): return n…

Maclaurin Expansion of the Telegrapher’s Equation and Python Implementation

Kac(Kac, 1974) proved his stochastic model can express the telegrapher’s equa- tion(1). In this report, I would like to predict a function F(x, t) with using the Maclaurin ex- pansion. The expansion of F(x, t) is showed like (2). When we d…

Science of the appetite(Sakurai, 2012)

Chapter 1 Origin of appetite Feature of weight: homeostatically weight is controlled a specific part of brain: the hypothalamus which is related to basic desires such as appetite, sleep, emotion. fear and excitement is sent from the limbic…

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