This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Base.show | |
using Formatting | |
typealias AA AbstractArray | |
function xvec!(x, row) | |
m = length(row) | |
row[1] = 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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): |