Skip to content

Instantly share code, notes, and snippets.

@statkclee
Last active November 29, 2015 01:00
Show Gist options
  • Save statkclee/ee16d329dd21b04c905a to your computer and use it in GitHub Desktop.
Save statkclee/ee16d329dd21b04c905a to your computer and use it in GitHub Desktop.
Think Stats 2, 3장 연습문제
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"통계적 사고 (2판) 연습문제 ([thinkstats2.com](thinkstats2.com), [think-stat.xwmooc.org](http://think-stat.xwmooc.org))<br>\n",
"Allen Downey / 이광춘(xwMOOC)\n",
"\n",
"여성 응답자 파일을 읽어들인다."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline\n",
"\n",
"import chap01soln\n",
"resp = chap01soln.ReadFemResp()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"응답자 가구에서 18세 이하 자녀수, <tt>numkdhh</tt>에 대한 PMF를 생성하라."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"PMF를 화면에 표시하라."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<tt>BiasPmf</tt>를 정의하시오."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"def BiasPmf(pmf, label=''):\n",
" \"\"\"Returns the Pmf with oversampling proportional to value.\n",
"\n",
" If pmf is the distribution of true values, the result is the\n",
" distribution that would be seen if values are oversampled in\n",
" proportion to their values; for example, if you ask students\n",
" how big their classes are, large classes are oversampled in\n",
" proportion to their size.\n",
"\n",
" Args:\n",
" pmf: Pmf object.\n",
" label: string label for the new Pmf.\n",
"\n",
" Returns:\n",
" Pmf object\n",
" \"\"\"\n",
" new_pmf = pmf.Copy(label=label)\n",
"\n",
" for x, p in pmf.Items():\n",
" new_pmf.Mult(x, x)\n",
" \n",
" new_pmf.Normalize()\n",
" return new_pmf"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"응답자 대신에 자녀를 설문조사하면 관측되듯이, 가구 자녀수에 대한 편향된 Pmf를 생성하시오."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"실제 Pmf와 편향된 Pmf를 동일축으로 화면에 표시하시오."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"두 Pmf의 평균을 계산하시오."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.10"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment