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
#coding:utf-8 | |
import time | |
import serial | |
import sys | |
""" | |
参考: pyserial公式ドキュメント | |
[1]サイトトップ http://pythonhosted.org/pyserial/ | |
[2]API一覧 http://pythonhosted.org/pyserial/pyserial_api.html | |
[3]イントロダクション http://pythonhosted.org/pyserial/shortintro.html |
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 serial | |
from serial.tools import list_ports | |
import time | |
def select_port(): | |
ser = serial.Serial() | |
ser.baudrate = 19200 # ArduinoのSerial.beginで指定した値 | |
ser.timeout = 0.1 # タイムアウトの時間 | |
ports = list_ports.comports() # ポートデータを取得 |
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
#coding:utf-8 | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import pandas as pd | |
from scipy.spatial import distance as dis | |
""" | |
参考URL | |
[1] 蟻コロニー最適化 - Wikipedia https://ja.wikipedia.org/wiki/蟻コロニー最適化 | |
[2] 任意の確率密度分布に従う乱数の生成(von Neumannの棄却法) | Pacocat's Life http://pacocat.com/?p=596 |
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
#coding:utf-8 | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import pandas as pd | |
from scipy.spatial import distance as dis | |
class TSP: | |
def __init__(self,path=None,n_gene = 256,n_parent = 10,change_ratio = 0.1): | |
""" 初期化を行う関数 """ | |
self.n_gene = n_gene # 一世代の遺伝子の個数 |
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
// フーリエ級数可視化クラス | |
class FourierPlotter { | |
int n_data; // データの個数 | |
int n_approx; // 近似次数 | |
float[][] radius; // 半径.radius[0][k]にsin成分のk次の成分が入る | |
float[] data; // データ | |
float centerX; // 中心X座標 | |
float centerY; // 中心Y座標 | |
float phase; // 位相のズレ | |
public float x; // 先端部分の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
#coding:utf-8 | |
import cv2 | |
import numpy as np | |
import time | |
import matplotlib.pyplot as plt | |
import pandas as pd | |
from scipy.spatial import distance as dis | |
""" | |
参考URL |
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
class FourierPlotter { | |
int n_data; // データの個数 | |
int n_approx; // 近似次数 | |
float[][] radius; // 半径 | |
float[] data; // データ | |
float centerX; // 中心X座標 | |
float centerY; // 中心Y座標 | |
float phase; // 位相のズレ | |
public float x; // 先端部分のX座標 | |
public float y; // 先端部分のY座標 |
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
#coding:utf-8 | |
import numpy as np | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
import wave | |
from scipy import signal | |
""" | |
参考 | |
[1] 波形を見る - 人工知能に関する断創録 http://aidiary.hatenablog.com/entry/20110519/1305808715 |
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
/* Euler法による微分方程式 f' - 2f = x の計算 */ | |
#include <stdio.h> | |
#include <math.h> | |
double g(double x,double fx){ | |
return x + 2.0 * fx; | |
} | |
int main(void){ | |
int k; // ループカウンタ |
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
/* 修正Euler法による微分方程式 f' - 2f = x の計算 */ | |
#include <stdio.h> | |
#include <math.h> | |
double g(double x,double fx){ | |
return x + 2.0 * fx; | |
} | |
int main(void){ | |
int k; // ループカウンタ |