βshortの自堕落Diary

web関係や、プログラミングなどを扱う予定です。プランなど立てていないので、不定期投稿になります。

2017-07-01から1ヶ月間の記事一覧

ガウス分布

ガウス分布 グラフ としたとき import math import numpy as np import matplotlib.pyplot as plt def gauss(x): return 1/(math.sqrt(2*math.pi))*np.exp((-x**2)/2) x = np.arange(-5.0, 5.0, 0.1) y = gauss(x) plt.plot(x, y, label = "Gauss") plt.xlab…

ReLU関数

ReLU関数ReLUとは、Rectified Linear Unitの略である。 入力が0を超えていれば、その入力をそのまま出力し、0以下ならば0を出力する関数。 import numpy as np import matplotlib.pylab as plt def relu(x): return np.maximum(0,x) x = np.arange(-5.0, 5.0…

ステップ関数とシグモイド関数

ステップ関数入力が0を超えたら1を出力し、それ以外は0を出力する関数。 単純に def step_function(x): if x > 0: return 1 else: return 0 と記述できる。シグモイド関数 def sigmoid(x): return 1 / (1+np.exp(-x)) それぞれのグラフ比較 import numpy as…

sin波とcos波

import numpy as np import matplotlib.pyplot as plt x = np.arange(0, 6, 0.1) y1 = np.sin(x) y2 = np.cos(x) plt.plot(x, y1, label = "sin") plt.plot(x, y2, linestyle = "--", label = "cos") plt.xlabel("x") plt.ylabel("y") plt.title('sin & cos'…

ユークリッドの互除法

ユークリッドの互除法ユークリッドの互除法を用いて、2つの整数の最大公約数を出力するC++のコードを作成する。 環境は、Xcodeである。 前回のコンソール入出力の利用です。 ユークリッドの互除法 ソースコード 実行結果 まとめ 参考 ソースコード #inclu…

C++のコンソール入出力

C++のコンソール入出力の仕方演算子" > "を使う。 各演算子を使うには、ヘッダをインクルードする必要がある。 Xcodeで、作成する。Example #include <iostream> using namespace std; int main() { int i; double d; char s[30]; cout <<"整数値、浮動小数点数値、文</iostream>…