ThinkStats (6)
第一子と第二子以降の妊娠期間を表すヒストグラムの描画にトライ。演習問題 2-2 のソレをパクることが可能ですね。リスト作るところまではそのまんまで
# -*- coding: utf-8 -*- import survey import thinkstats import math import Pmf table = survey.Pregnancies() table.ReadRecords() first_p = [] other_p = [] for i in table.records: if i.outcome == 1: if i.birthord == 1: first_p.append(i.prglength) else: other_p.append(i.prglength)
あとはこれらを MakeHistFromList して
first_hist = Pmf.MakeHistFromList(first_p) other_hist = Pmf.MakeHistFromList(other_p)
描画、なのかな。ちょっとここまでを REPL に食わせてみます。む、一つづつだと駄目ですね。あ、myplot.py を云々、なのかな。
ドキュメントを見るに
Hists という手続きがありますね。Plots two histgrams as interleaved bar plots. とあるのでこれを使えば良いのかな。ファイルを入手して
import myplot
して
myplot.Hists([first_hist, other_hist])
してみたのですがだんまり状態。そろそろ出かけるようなので一旦止め。出かけるまでに進捗があって追記可能であれば追記するかもしれません。