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
@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
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 / 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)")
"""
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 / error_correction.jl
Last active December 4, 2016 14:44
Error correction algorithm of the linear code
using DataStructures
function int_to_binarray(number, array_length)
"""
Convert the given number into a fixed length binary array
"""
binstring = bin(number)
# padding for alignment of the lengths of vectors
The MIT License (MIT)
Copyright (c) 2016 Ishita Takeshi
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@IshitaTakeshi
IshitaTakeshi / judge_prefix_code.py
Created June 25, 2016 15:46
Judge whether given code is a prefix code or not
from copy import copy
def dangling_suffixes(code1, code2):
def suffixes(code, word):
N = len(word)
s = set()
for c in code:
if c == word:
continue
@IshitaTakeshi
IshitaTakeshi / regression.jl
Last active March 16, 2016 07:57
Polynomial Regression in Julia
import Base.show
using Formatting
typealias AA AbstractArray
function xvec!(x, row)
m = length(row)
row[1] = 1
@IshitaTakeshi
IshitaTakeshi / svmlight_loader.jl
Last active August 29, 2015 14:27
svmlight / liblinear format file loader
# svmlight / liblinear format file loader
# The MIT License (MIT)
#
# Copyright (c) 2015 Ishita Takeshi
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@IshitaTakeshi
IshitaTakeshi / kalman.py
Last active August 29, 2015 14:17
The kalman filter
#!/usr/bin/python
# -*- coding: utf-8 -*-
import numpy as np
from matplotlib import pyplot
from numpy.random import multivariate_normal
class StateViewer(object):
def __init__(self, dt, n_iterations):