以前からPythonの勉強をしていきたいという話はどこかでしたような気がする。
ゆっくりとながら進めており、Pythonの参考書は一冊終了した。一応VBAをやっていたので、簡単なIf, for分の概念は理解は早かったので良かったと思う。
それでPythonの基本的なところは抑えられたと信じて、ライブラリを使っていきたい。
データ分析や計算用途に使用するので、NumpyやPandas, Matplotlibあたりを進めたいと思っている。
それでNumpyを勉強しているところである。
Pythonをあまり知らない人のために説明をしておくと、ライブラリとはPythonで用意された、ある目的のために機能をまとめたパッケージの総称を指す言葉である。
そのため、プログラマーがそれぞれ自分で書く必要がなく、そのライブラリを呼び出すことでプログラムを円滑に進めることができるという優れものである。
Numpyではデータや情報処理に特化しており、配列だったり多次元数値配列を扱うことができる。
数学でいうところの行列計算が可能になるので、最近話題の機械学習などでは欠かせないライブラリとなる。
まぁそんなわけでネットで調べながらいろいろな課題に取り組んでいる。
今日の課題はNumpyでsin関数とcos関数を描いてみようということでやってみた。
from matplotlib import pyplot as plt import numpy as np sinx = [] cosx = [] ndata = np.arange(0, 2 * np.pi, 0.01) for i in ndata: a = np.sin(i) b = np.cos(i) sinx.append(a) cosx.append(b) plt.plot(ndata, sinx) plt.plot(ndata, cosx) plt.show()

生成されたグラフが上のようになる。
いろいろと調べてみると軸ラベルや凡例、グラフのサイズだったりを変更することが可能。
あとはFigを加えていくことで別々にグラフを描画することもできる。
Pythonはあまり早いプログラミング言語ではないそうで、大量のデータを扱う場合などはアルゴリズムの構成とかも考えないといけないみたい。
たとえば、for文は逐次進行のプログラムなので、回数が多くなるとかなり速度が落ちてしまう。
次回はsin, cosの応用として円を描くのでもやってみようかな。
コメント
order stromectol – carbamazepine 200mg generic buy tegretol generic
buy isotretinoin generic – buy accutane 40mg sale linezolid tablet
buy generic amoxil over the counter – buy combivent online cheap ipratropium 100mcg us
zithromax 500mg without prescription – brand tinidazole buy generic nebivolol online
generic prednisolone 40mg – order omnacortil 5mg generic where can i buy prometrium
order furosemide 40mg for sale – order lasix 100mg pill buy betnovate 20gm creams
neurontin 100mg drug – order generic neurontin order itraconazole 100 mg without prescription
augmentin 625mg pill – oral duloxetine 40mg buy cymbalta 40mg pill
monodox oral – oral monodox order glipizide 10mg for sale
buy augmentin pills for sale – buy augmentin medication cymbalta buy online
buy semaglutide 14 mg online cheap – rybelsus 14mg uk cyproheptadine 4 mg uk
purchase tizanidine without prescription – plaquenil order online order microzide 25mg
cialis for men over 50 – buy tadalafil 10mg for sale sildenafil tablets
order sildenafil 50mg online cheap – cialis tadalafil 40mg buy tadalafil 5mg pills
purchase atorvastatin pill – order amlodipine 10mg without prescription lisinopril order
cenforce price – cenforce 50mg generic glucophage 500mg brand
lipitor 20mg brand – purchase prinivil pill buy lisinopril sale
order atorvastatin 10mg without prescription – buy generic lisinopril over the counter buy cheap generic zestril
purchase prilosec pill – purchase omeprazole pill atenolol 100mg sale
depo-medrol buy – pregabalin 150mg tablet order aristocort 4mg without prescription