βshortの自堕落Diary

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

python

カレンダー[python]

pythonでカレンダーを表示する。標準ライブラリのcalendarを紹介します。 とても簡単で、紹介する意味も皆無?笑ソースコードと参考画像などを貼り付けていきます。 import calendar print( calendar.month(2017, 9))

tkinterその2

前回の続きweblog2016it.hatenablog.com学んだこと 矩形を作る キャンバス上に作ったものを消す 強制的に画面を更新する 一定時間処理をストップさせる キーボードで移動させる 描画済みの画像を動かす キャンバス上に文字を書く 矩形を作るキャンバス上に矩…

tkinterその1

tkinterを使うその1昨日公開しましたtkinterで画像を表示の続きとして、勉強したことのメモ(記録)として、このブログで残したいと思います。 なお、勉強の教材は、Pythonプログラミングパーフェクトマスター (Perfect Master)と12歳からはじめる ゼロから…

ガウス分布

ガウス分布 グラフ としたとき 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'…

放物運動

from matplotlib import pyplot as pltimport math def draw_graph(x,y): #グラフの生成 plt.plot(x,y) plt.xlabel('距離') plt.ylabel('高さ') plt.title('放物運動') def frange(start, final, interval): #時間間隔 numbers = while start < final: numbe…

Anacandaのインストールfor Mac

追加情報 weblog2016it.hatenablog.com weblog2016it.hatenablog.com weblog2016it.hatenablog.com AnacondaでPythonの開発環境を整える ここでは、Pythonとそのパッケージ各種を一括でインストールできるanacondaのインストールの仕方を説明します。 はじめ…