Skip to content

Instantly share code, notes, and snippets.

View IshitaTakeshi's full-sized avatar
💭
kernel panic

Takeshi Ishita IshitaTakeshi

💭
kernel panic
View GitHub Profile
"""
A*アルゴリズムの実装です.
手順はWikipedia(https://ja.wikipedia.org/wiki/A*)の解説と同じです
"""
def generate_path(parents, start_node, goal_node):
"""経路上のノードの親子関係を記録した辞書(parents)から経路を復元する"""
c = goal_node
path = [goal_node]
while c != start_node:
@IshitaTakeshi
IshitaTakeshi / bisection.jl
Last active September 30, 2017 14:33
Numerical Analysis
function plot_bisection_method(f, a, b;
n_max_iter=20, n_samples=100, interval=1000)
xrange, yrange, xs, ys = init_xs_ys(f, a, b, n_samples)
fig, ax = init_figure_plot()
function draw(i)
cla()
ax[:set_xlabel]("x")
ax[:set_ylabel]("f(x)")
from itertools import permutations, combinations
import numpy as np
from numpy.linalg import det
from matplotlib.patches import FancyArrowPatch
from matplotlib import pyplot as plt
from mpl_toolkits.mplot3d import proj3d
from mpl_toolkits.mplot3d import Axes3D
@IshitaTakeshi
IshitaTakeshi / lagrange_interpolation.jl
Last active June 29, 2017 00:57
Lagrange Interpolation
using PyPlot
using PyCall
function generate_Lᵢ(xs, ys, i)
function Lᵢ(x)
n, d = 1, 1
for (j, xⱼ) in enumerate(xs)
if i == j
continue
using Base.Test
function integrate(f, a, b, n_samples=100)
assert(b > a)
h = (b - a) / n_samples
xs = linspace(a, b, n_samples)
ys = [f(x) for x in xs]
h * ((ys[1] + ys[end]) / 2 + sum(ys[2:end-1]))
end
@IshitaTakeshi
IshitaTakeshi / integration.jl
Last active September 19, 2017 21:13
Numerical Integration
using Base.Test
using Iterators: filter
using Distributions
function h_xs_ys(f, a, b, n_parts)
h = (b - a) / n_parts
xs = linspace(a, b, n_parts + 1)
ys = [f(x) for x in xs]
h, xs, ys
@IshitaTakeshi
IshitaTakeshi / doc2vec.py
Created September 8, 2017 15:47
Innovation Project
from xml.etree import ElementTree as ET
from bs4 import BeautifulSoup
from gensim.models.doc2vec import Doc2Vec, TaggedDocument, DocvecsArray
# root = tree.getroot()
# for neighbor in root.iter("neighbor"):
# print(neighbor)
MIN_LINE_LENGTH = 80
def generate_documents():
using PyPlot
using PyCall
PyDict(pyimport("matplotlib")["rcParams"])["font.size"] = 18
include("ode_solvers.jl")
f(x, y) = -3sin(10*x) / exp(x+y^2)
import numpy as np
from matplotlib.animation import FuncAnimation
from matplotlib import pyplot as plt
from mcl import Environment, MCL, Agent
def particle_weight(particle_observation, agent_observation):
return 1 if particle_observation == agent_observation else 0
import numpy as np
from matplotlib.animation import FuncAnimation
from matplotlib import pyplot as plt
from mcl import Environment, MCL, Agent
def particle_weight(particle_observation, agent_observation):
return 1 if particle_observation == agent_observation else 0