From fb6f44c65174edbaac2264fec27505c6eb19b081 Mon Sep 17 00:00:00 2001 From: SkylarShi Date: Sat, 1 Jun 2024 01:55:49 -0700 Subject: [PATCH] Deploy website - based on e68c1ee86d58cb4c3666cef2e442af8380d4c62f --- 404.html | 2 +- ...test2-7615aa5325b73c6c19541b78e2619a30.png | Bin 0 -> 22439 bytes assets/js/60c4aef6.04bec992.js | 1 + assets/js/60c4aef6.bacecd71.js | 1 - assets/js/9f1843d8.98b107ad.js | 1 + assets/js/9f1843d8.e87af32a.js | 1 - assets/js/d4f68316.39fbf26a.js | 1 + assets/js/d4f68316.a09dc9fc.js | 1 - assets/js/f03ae67e.4876c58e.js | 1 + assets/js/f03ae67e.fff9d33b.js | 1 - ...n.dda7f4e2.js => runtime~main.d66ee0d1.js} | 2 +- blog/archive/index.html | 2 +- blog/first-blog-post/index.html | 2 +- blog/index.html | 2 +- blog/long-blog-post/index.html | 2 +- blog/mdx-blog-post/index.html | 2 +- blog/tags/docusaurus/index.html | 2 +- blog/tags/facebook/index.html | 2 +- blog/tags/hello/index.html | 2 +- blog/tags/hola/index.html | 2 +- blog/tags/index.html | 2 +- blog/welcome/index.html | 2 +- docs/category/if-statements/index.html | 2 +- docs/category/querying/index.html | 2 +- .../Functions/Applying Functions/index.html | 2 +- .../Functions/Writing Functions/index.html | 2 +- .../Grouping/aggregation/count()/index.html | 2 +- .../Grouping/aggregation/max()/index.html | 2 +- .../Grouping/aggregation/mean()/index.html | 2 +- .../Grouping/aggregation/median()/index.html | 2 +- .../Grouping/aggregation/min()/index.html | 2 +- .../Grouping/aggregation/sum()/index.html | 2 +- .../documentation/Grouping/groupby/index.html | 2 +- .../accessing-data/df.columns/index.html | 2 +- .../accessing-data/df.get()/index.html | 2 +- .../accessing-data/df.index/index.html | 2 +- .../accessing-data/df.shape/index.html | 2 +- .../accessing-data/df.take()/index.html | 2 +- docs/documentation/accessing-data/index.html | 2 +- .../accessing-data/ser.iloc[]/index.html | 2 +- .../accessing-data/ser.loc[]/index.html | 2 +- .../arrays-and-numpy/arr[]/index.html | 2 +- .../documentation/arrays-and-numpy/index.html | 2 +- .../arrays-and-numpy/np.append()/index.html | 2 +- .../arrays-and-numpy/np.arange()/index.html | 2 +- .../np.count_nonzero()/index.html | 2 +- .../np.percentile()/index.html | 2 +- .../arrays-and-numpy/np.round()/index.html | 2 +- .../bpd.DataFrame()/index.html | 2 +- .../bpd.read_csv()/index.html | 2 +- .../df.assign()/index.html | 2 +- .../building-organizing/df.drop()/index.html | 2 +- .../building-organizing/df.merge()/index.html | 2 +- .../df.reset_index()/index.html | 2 +- .../df.set_index()/index.html | 2 +- .../df.sort_values()/index.html | 2 +- .../building-organizing/index.html | 2 +- .../data format conversion/index.html | 2 +- .../data format conversion/list()/index.html | 2 +- .../np.array()/index.html | 2 +- docs/documentation/for-loops/index.html | 2 +- .../Logical Operators/index.html | 2 +- .../if-statements/if-elif-else/index.html | 2 +- .../in \342\201\204 not in/index.html" | 2 +- docs/documentation/intro/index.html | 2 +- .../plotting/Bar Plot/index.html | 2 +- .../plotting/Histogram/index.html | 2 +- .../plotting/Line Plot/index.html | 2 +- .../plotting/Scatter Plot/index.html | 2 +- docs/documentation/plotting/index.html | 2 +- docs/documentation/querying/df[]/index.html | 2 +- docs/documentation/series-methods/index.html | 2 +- .../series-methods/ser.count()/index.html | 2 +- .../series-methods/ser.max()/index.html | 2 +- .../series-methods/ser.mean()/index.html | 2 +- .../series-methods/ser.median()/index.html | 2 +- .../series-methods/ser.min()/index.html | 2 +- .../ser.str.capitalize()/index.html | 2 +- .../ser.str.contains()/index.html | 2 +- .../series-methods/ser.str.len()/index.html | 2 +- .../series-methods/ser.str.lower()/index.html | 2 +- .../ser.str.replace()/index.html | 2 +- .../series-methods/ser.str.split()/index.html | 2 +- .../series-methods/ser.str.strip()/index.html | 2 +- .../series-methods/ser.str.title()/index.html | 2 +- .../series-methods/ser.str.upper()/index.html | 2 +- .../series-methods/ser.sum()/index.html | 2 +- .../series-methods/ser.unique()/index.html | 2 +- .../bootstrapping/index.html | 2 +- .../hypothesis_vs_permutation/index.html | 6 +-- .../hypothesis_test/index.html | 40 +++++++++++++++--- docs/statistical-inference/intro/index.html | 2 +- .../null_and_alt/index.html | 2 +- .../obs_and_test_stats/index.html | 24 +++++------ docs/statistical-inference/p_value/index.html | 2 +- .../parameters-and-statistics/index.html | 2 +- .../permutation_test/index.html | 6 +-- .../random sampling/df.sample()/index.html | 2 +- .../np.random.choice()/index.html | 2 +- .../np.random.multinomial()/index.html | 2 +- .../np.random.permutation()/index.html | 2 +- .../random sampling/sampling/index.html | 2 +- .../standard_normal_distribution/index.html | 2 +- .../standard_units/index.html | 2 +- docs/tags/correlation/index.html | 2 +- docs/tags/for-loop/index.html | 2 +- docs/tags/functions/index.html | 2 +- docs/tags/histogram/index.html | 2 +- docs/tags/index.html | 2 +- docs/tags/normal-distributions/index.html | 2 +- docs/tags/querying/index.html | 2 +- docs/tags/regression/index.html | 2 +- docs/tags/standard-units/index.html | 2 +- .../hypothesis-test2.png | Bin 0 -> 22439 bytes index.html | 2 +- search/index.html | 2 +- 116 files changed, 157 insertions(+), 131 deletions(-) create mode 100644 assets/images/hypothesis-test2-7615aa5325b73c6c19541b78e2619a30.png create mode 100644 assets/js/60c4aef6.04bec992.js delete mode 100644 assets/js/60c4aef6.bacecd71.js create mode 100644 assets/js/9f1843d8.98b107ad.js delete mode 100644 assets/js/9f1843d8.e87af32a.js create mode 100644 assets/js/d4f68316.39fbf26a.js delete mode 100644 assets/js/d4f68316.a09dc9fc.js create mode 100644 assets/js/f03ae67e.4876c58e.js delete mode 100644 assets/js/f03ae67e.fff9d33b.js rename assets/js/{runtime~main.dda7f4e2.js => runtime~main.d66ee0d1.js} (97%) create mode 100644 img/statistical-inference-plots/hypothesis-test2.png diff --git a/404.html b/404.html index f4fee58f..39c0ae04 100644 --- a/404.html +++ b/404.html @@ -11,7 +11,7 @@ - + diff --git a/assets/images/hypothesis-test2-7615aa5325b73c6c19541b78e2619a30.png b/assets/images/hypothesis-test2-7615aa5325b73c6c19541b78e2619a30.png new file mode 100644 index 0000000000000000000000000000000000000000..dc5d4c08e0cd6d7a6f1ad3e82c98bd2010bdd652 GIT binary patch literal 22439 zcmeIa2T+ySwl%udR@(rySwO&m0Z>q)WQ+s}l9i|;C>e>8v2CSQ1jT@Wf(nw8lCw67 zAOezwO_UrqImdsjZJ%@RdGFS(^XkbBr;^{O+7pmStGWvX(-j zFv!cDRHIN<^iU|v#(!OfpClYueF%Sv+MhaSuWoH(?{v}Dn4)yi-p0b(-oo_KPDf)~ zJ5y^b0bU{ABL{b0wYRsi6XWBv{O1dJt!=OHeZM%Giw{|2BX{18LSec{{#zC$9cfCT zXm6H3c}(N_b6S(r_05_~izBX8tZR00{;}~mQ?A_RWn8cR+`MJ;lhu++l9-hM`9_RfZEFVxFUdT$wwZ9VS z=2%wd@7n#9IrvE7ueb;bCF5~$>^l0tD8Ja#|2}xbi;?`pYvpg>mXUuXQI?C5zbRW~ zWLA^E-!K0aYl1)LD9hOB|5&&49lcoKVBKio`@n-pnr zQy=RpEvevVwv4@4a63jX)7H24(UV*2wwW|I?p1hvHh@>(s&~>VRVi3F`q<4?YuB#z zFEy#k9?A>03gOkyY8=jxcTKUVSHs7f)g|ahP|wK8JqQgAWq0Y>CEx2O&%wcQ%iEi0 z-@emt-@d);=T}}km$5i@HMxHCjvaA2sb;-ZD$=Djc@M*x1xzkys0?mi&A7wn`xPrI ztF>#^sNUOpD8-T1up`mBG)Ra=$}MAYraM$u=ZcwGjMUP+osene$(8H2K8}ox{Ohm3 zs$(>H+^3qH6qJ-oN5t$#b6xlMR=&BX@c6*PPB#WtVf$&lj*1sCn`ZdTTD?!d|#qo=IiO{>kH#m zDlC#NDT{M0OJ=+LKe=v0XI9X9BbkZM1Se{VYx{cj_56oCcvQWjmBYrSx-MrAJe=*QeIS8|E7bTq*miDYKM* zz#u2XJ-;SiR~zB0+Fp2H=;B|$D1}JWze#1-epm)KQ5zZR5u^MAtE+zpkk~)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D&}}{a.r(e),a.d(e,{assets:()=>c,contentTitle:()=>l,default:()=>d,frontMatter:()=>t,metadata:()=>r,toc:()=>m});var n=a(4848),i=a(8453);a(8597),a(5158);const t={sidebar_position:4,sidebar_label:"Observed & Test Statistic",title:"Observed & Test Statistic"},l=void 0,r={id:"statistical-inference/obs_and_test_stats",title:"Observed & Test Statistic",description:"Concept",source:"@site/docs/statistical-inference/obs_and_test_stats.md",sourceDirName:"statistical-inference",slug:"/statistical-inference/obs_and_test_stats",permalink:"/bpd-reference/docs/statistical-inference/obs_and_test_stats",draft:!1,unlisted:!1,editUrl:"https://github.com/dsc-courses/bpd-reference/tree/main/docs/statistical-inference/obs_and_test_stats.md",tags:[],version:"current",sidebarPosition:4,frontMatter:{sidebar_position:4,sidebar_label:"Observed & Test Statistic",title:"Observed & Test Statistic"},sidebar:"statsSidebar",previous:{title:"Null & Alternative Hypothesis",permalink:"/bpd-reference/docs/statistical-inference/null_and_alt"},next:{title:"P-value",permalink:"/bpd-reference/docs/statistical-inference/p_value"}},c={},m=[{value:"Concept",id:"concept",level:2},{value:"Common Test Statistics \ud83c\udf1f",id:"common-test-statistics-",level:2},{value:"1. Absolute Difference",id:"1-absolute-difference",level:3},{value:"2. Difference",id:"2-difference",level:3},{value:"3. Total Variation Distance (TVD)",id:"3-total-variation-distance-tvd",level:3}];function h(s){const e={a:"a",admonition:"admonition",annotation:"annotation",br:"br",code:"code",em:"em",h2:"h2",h3:"h3",li:"li",math:"math",mfrac:"mfrac",mi:"mi",mn:"mn",mo:"mo",mrow:"mrow",msub:"msub",mtext:"mtext",ol:"ol",p:"p",pre:"pre",semantics:"semantics",span:"span",strong:"strong",ul:"ul",...(0,i.R)(),...s.components};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(e.h2,{id:"concept",children:"Concept"}),"\n",(0,n.jsxs)(e.admonition,{title:"Terminology",type:"info",children:[(0,n.jsxs)(e.p,{children:[(0,n.jsx)(e.strong,{children:"Experiment"}),": A process whose outcome is random."]}),(0,n.jsxs)(e.ul,{children:["\n",(0,n.jsx)(e.li,{children:"Example: Flipping 100 coins."}),"\n"]}),(0,n.jsxs)(e.p,{children:[(0,n.jsx)(e.strong,{children:"Observed Statistic"}),": A statistic computed from the observed data."]}),(0,n.jsxs)(e.ul,{children:["\n",(0,n.jsx)(e.li,{children:"Example: The number of heads observed."}),"\n"]}),(0,n.jsxs)(e.p,{children:[(0,n.jsx)(e.strong,{children:"Test Statistic"}),": A statistic computed from a sample generated under the assumption that the null hypothesis is true."]}),(0,n.jsxs)(e.ul,{children:["\n",(0,n.jsx)(e.li,{children:"Think of the test statistic a number you write down each time you perform an experiment."}),"\n",(0,n.jsx)(e.li,{children:"The test statistic should be such that high observed values lean towards one hypothesis and low observed values lean towards the other."}),"\n"]})]}),"\n",(0,n.jsx)(e.h2,{id:"common-test-statistics-",children:"Common Test Statistics \ud83c\udf1f"}),"\n",(0,n.jsx)(e.h3,{id:"1-absolute-difference",children:"1. Absolute Difference"}),"\n",(0,n.jsx)(e.p,{children:"Absolute difference in group mean/median/number of times a certain event happens."}),"\n",(0,n.jsxs)(e.ul,{children:["\n",(0,n.jsxs)(e.li,{children:["\u2705 Used for measuring how different two ",(0,n.jsx)(e.strong,{children:"numerical distributions"})," are, and when the alternative hypothesis is ",(0,n.jsx)(e.strong,{children:(0,n.jsx)(e.em,{children:"not equal to"})}),'. For example, "the coin is biased" or "the probability of tossing a head is 0.5".']}),"\n",(0,n.jsxs)(e.li,{children:["\ud83d\udcbb ",(0,n.jsx)(e.a,{href:"https://dsc-courses.github.io/bpd-reference/docs/statistical-inference/permutation_test#code-example-absolute-difference",children:"Example"})," of using absolute difference as the test statistic in a permutation test."]}),"\n"]}),"\n",(0,n.jsx)(e.h3,{id:"2-difference",children:"2. Difference"}),"\n",(0,n.jsx)(e.p,{children:"Difference in group mean/median/number of times a certain event happens."}),"\n",(0,n.jsxs)(e.ul,{children:["\n",(0,n.jsxs)(e.li,{children:["\u2705 Used for measuring how different two ",(0,n.jsx)(e.strong,{children:"numerical distributions"})," are, and the alternative hypothesis is ",(0,n.jsx)(e.strong,{children:(0,n.jsx)(e.em,{children:"less than"})})," or ",(0,n.jsx)(e.strong,{children:(0,n.jsx)(e.em,{children:"greater than"})}),'. For example, "the coin is biased towards heads" or "the probability of tossing a head is greater then 0.5".']}),"\n",(0,n.jsxs)(e.li,{children:["\ud83d\udcbb ",(0,n.jsx)(e.a,{href:"https://dsc-courses.github.io/bpd-reference/docs/statistical-inference/hypothesis_test#code-example-1-difference",children:"Example"})," of using difference as the test statistic in a hypothesis test."]}),"\n"]}),"\n",(0,n.jsx)(e.h3,{id:"3-total-variation-distance-tvd",children:"3. Total Variation Distance (TVD)"}),"\n",(0,n.jsxs)(e.p,{children:["A test statistic that quantifies how different ",(0,n.jsx)(e.strong,{children:"two categorical distributions"})," are by calculating the sum of the absolute differences of their proportions, all divided by 2."]}),"\n",(0,n.jsxs)(e.ul,{children:["\n",(0,n.jsx)(e.li,{children:"\u274c\ufe0f The TVD is not used for permutation tests."}),"\n",(0,n.jsxs)(e.li,{children:['\u2705 Used for assessing whether an "observed sample" was drawn randomly from a known ',(0,n.jsx)(e.strong,{children:"categorical distribution"}),"."]}),"\n",(0,n.jsxs)(e.li,{children:["\ud83d\udcbb ",(0,n.jsx)(e.a,{href:"https://dsc-courses.github.io/bpd-reference/docs/statistical-inference/hypothesis_test#code-example-2-tvd",children:"Example"})," of using TVD as the test statistic in a hypothesis test."]}),"\n"]}),"\n",(0,n.jsx)(e.pre,{children:(0,n.jsx)(e.code,{className:"language-python",children:"#code implementation\ndef tvd(dist1, dist2):\n '''Computes the TVD between two categorical distributions, \n assuming the categories appear in the same order.'''\n return np.abs(dist1 - dist2).sum() / 2\n"})}),"\n",(0,n.jsxs)(e.admonition,{type:"note",children:[(0,n.jsxs)(e.p,{children:[(0,n.jsx)(e.strong,{children:"3 Ways of Manually Computing TVD:"})," \ud83e\uddee"]}),(0,n.jsx)(e.p,{children:"to do: use an example"}),(0,n.jsx)(e.p,{children:(0,n.jsxs)(e.em,{children:["Assume ",(0,n.jsxs)(e.span,{className:"katex",children:[(0,n.jsx)(e.span,{className:"katex-mathml",children:(0,n.jsx)(e.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,n.jsxs)(e.semantics,{children:[(0,n.jsx)(e.mrow,{children:(0,n.jsxs)(e.msub,{children:[(0,n.jsx)(e.mi,{children:"P"}),(0,n.jsx)(e.mi,{children:"i"})]})}),(0,n.jsx)(e.annotation,{encoding:"application/x-tex",children:"P_i"})]})})}),(0,n.jsx)(e.span,{className:"katex-html","aria-hidden":"true",children:(0,n.jsxs)(e.span,{className:"base",children:[(0,n.jsx)(e.span,{className:"strut",style:{height:"0.8333em",verticalAlign:"-0.15em"}}),(0,n.jsxs)(e.span,{className:"mord",children:[(0,n.jsx)(e.span,{className:"mord mathnormal",style:{marginRight:"0.13889em"},children:"P"}),(0,n.jsx)(e.span,{className:"msupsub",children:(0,n.jsxs)(e.span,{className:"vlist-t vlist-t2",children:[(0,n.jsxs)(e.span,{className:"vlist-r",children:[(0,n.jsx)(e.span,{className:"vlist",style:{height:"0.3117em"},children:(0,n.jsxs)(e.span,{style:{top:"-2.55em",marginLeft:"-0.1389em",marginRight:"0.05em"},children:[(0,n.jsx)(e.span,{className:"pstrut",style:{height:"2.7em"}}),(0,n.jsx)(e.span,{className:"sizing reset-size6 size3 mtight",children:(0,n.jsx)(e.span,{className:"mord mathnormal mtight",children:"i"})})]})}),(0,n.jsx)(e.span,{className:"vlist-s",children:"\u200b"})]}),(0,n.jsx)(e.span,{className:"vlist-r",children:(0,n.jsx)(e.span,{className:"vlist",style:{height:"0.15em"},children:(0,n.jsx)(e.span,{})})})]})})]})]})})]})," is one distribution and ",(0,n.jsxs)(e.span,{className:"katex",children:[(0,n.jsx)(e.span,{className:"katex-mathml",children:(0,n.jsx)(e.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,n.jsxs)(e.semantics,{children:[(0,n.jsx)(e.mrow,{children:(0,n.jsxs)(e.msub,{children:[(0,n.jsx)(e.mi,{children:"Q"}),(0,n.jsx)(e.mi,{children:"i"})]})}),(0,n.jsx)(e.annotation,{encoding:"application/x-tex",children:"Q_i"})]})})}),(0,n.jsx)(e.span,{className:"katex-html","aria-hidden":"true",children:(0,n.jsxs)(e.span,{className:"base",children:[(0,n.jsx)(e.span,{className:"strut",style:{height:"0.8778em",verticalAlign:"-0.1944em"}}),(0,n.jsxs)(e.span,{className:"mord",children:[(0,n.jsx)(e.span,{className:"mord mathnormal",children:"Q"}),(0,n.jsx)(e.span,{className:"msupsub",children:(0,n.jsxs)(e.span,{className:"vlist-t vlist-t2",children:[(0,n.jsxs)(e.span,{className:"vlist-r",children:[(0,n.jsx)(e.span,{className:"vlist",style:{height:"0.3117em"},children:(0,n.jsxs)(e.span,{style:{top:"-2.55em",marginLeft:"0em",marginRight:"0.05em"},children:[(0,n.jsx)(e.span,{className:"pstrut",style:{height:"2.7em"}}),(0,n.jsx)(e.span,{className:"sizing reset-size6 size3 mtight",children:(0,n.jsx)(e.span,{className:"mord mathnormal mtight",children:"i"})})]})}),(0,n.jsx)(e.span,{className:"vlist-s",children:"\u200b"})]}),(0,n.jsx)(e.span,{className:"vlist-r",children:(0,n.jsx)(e.span,{className:"vlist",style:{height:"0.15em"},children:(0,n.jsx)(e.span,{})})})]})})]})]})})]})," is the other, and the categories appear in the same order"]})}),(0,n.jsxs)(e.ol,{children:["\n",(0,n.jsxs)(e.li,{children:["\n",(0,n.jsxs)(e.p,{children:[(0,n.jsx)(e.strong,{children:"Follow the definition:"})," Calculate the sum of the absolute differences of the two distributions' proportions, all divided by 2. ",(0,n.jsx)(e.br,{}),"\n",(0,n.jsxs)(e.span,{className:"katex",children:[(0,n.jsx)(e.span,{className:"katex-mathml",children:(0,n.jsx)(e.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,n.jsxs)(e.semantics,{children:[(0,n.jsxs)(e.mrow,{children:[(0,n.jsx)(e.mtext,{children:"TVD"}),(0,n.jsx)(e.mo,{children:"="}),(0,n.jsxs)(e.mfrac,{children:[(0,n.jsx)(e.mn,{children:"1"}),(0,n.jsx)(e.mn,{children:"2"})]}),(0,n.jsx)(e.mo,{children:"\u2211"}),(0,n.jsx)(e.mo,{children:"\u2223"}),(0,n.jsxs)(e.msub,{children:[(0,n.jsx)(e.mi,{children:"P"}),(0,n.jsx)(e.mi,{children:"i"})]}),(0,n.jsx)(e.mo,{children:"\u2212"}),(0,n.jsxs)(e.msub,{children:[(0,n.jsx)(e.mi,{children:"Q"}),(0,n.jsx)(e.mi,{children:"i"})]}),(0,n.jsx)(e.mo,{children:"\u2223"})]}),(0,n.jsx)(e.annotation,{encoding:"application/x-tex",children:"\\text{TVD}=\\frac{1}{2}\\sum \\mid P_i - Q_i\\mid"})]})})}),(0,n.jsxs)(e.span,{className:"katex-html","aria-hidden":"true",children:[(0,n.jsxs)(e.span,{className:"base",children:[(0,n.jsx)(e.span,{className:"strut",style:{height:"0.6833em"}}),(0,n.jsx)(e.span,{className:"mord text",children:(0,n.jsx)(e.span,{className:"mord",children:"TVD"})}),(0,n.jsx)(e.span,{className:"mspace",style:{marginRight:"0.2778em"}}),(0,n.jsx)(e.span,{className:"mrel",children:"="}),(0,n.jsx)(e.span,{className:"mspace",style:{marginRight:"0.2778em"}})]}),(0,n.jsxs)(e.span,{className:"base",children:[(0,n.jsx)(e.span,{className:"strut",style:{height:"1.1901em",verticalAlign:"-0.345em"}}),(0,n.jsxs)(e.span,{className:"mord",children:[(0,n.jsx)(e.span,{className:"mopen nulldelimiter"}),(0,n.jsx)(e.span,{className:"mfrac",children:(0,n.jsxs)(e.span,{className:"vlist-t vlist-t2",children:[(0,n.jsxs)(e.span,{className:"vlist-r",children:[(0,n.jsxs)(e.span,{className:"vlist",style:{height:"0.8451em"},children:[(0,n.jsxs)(e.span,{style:{top:"-2.655em"},children:[(0,n.jsx)(e.span,{className:"pstrut",style:{height:"3em"}}),(0,n.jsx)(e.span,{className:"sizing reset-size6 size3 mtight",children:(0,n.jsx)(e.span,{className:"mord mtight",children:(0,n.jsx)(e.span,{className:"mord mtight",children:"2"})})})]}),(0,n.jsxs)(e.span,{style:{top:"-3.23em"},children:[(0,n.jsx)(e.span,{className:"pstrut",style:{height:"3em"}}),(0,n.jsx)(e.span,{className:"frac-line",style:{borderBottomWidth:"0.04em"}})]}),(0,n.jsxs)(e.span,{style:{top:"-3.394em"},children:[(0,n.jsx)(e.span,{className:"pstrut",style:{height:"3em"}}),(0,n.jsx)(e.span,{className:"sizing reset-size6 size3 mtight",children:(0,n.jsx)(e.span,{className:"mord mtight",children:(0,n.jsx)(e.span,{className:"mord mtight",children:"1"})})})]})]}),(0,n.jsx)(e.span,{className:"vlist-s",children:"\u200b"})]}),(0,n.jsx)(e.span,{className:"vlist-r",children:(0,n.jsx)(e.span,{className:"vlist",style:{height:"0.345em"},children:(0,n.jsx)(e.span,{})})})]})}),(0,n.jsx)(e.span,{className:"mclose nulldelimiter"})]}),(0,n.jsx)(e.span,{className:"mspace",style:{marginRight:"0.1667em"}}),(0,n.jsx)(e.span,{className:"mop op-symbol small-op",style:{position:"relative",top:"0em"},children:"\u2211"}),(0,n.jsx)(e.span,{className:"mspace",style:{marginRight:"0.2778em"}}),(0,n.jsx)(e.span,{className:"mrel",children:"\u2223"}),(0,n.jsx)(e.span,{className:"mspace",style:{marginRight:"0.2778em"}})]}),(0,n.jsxs)(e.span,{className:"base",children:[(0,n.jsx)(e.span,{className:"strut",style:{height:"0.8333em",verticalAlign:"-0.15em"}}),(0,n.jsxs)(e.span,{className:"mord",children:[(0,n.jsx)(e.span,{className:"mord mathnormal",style:{marginRight:"0.13889em"},children:"P"}),(0,n.jsx)(e.span,{className:"msupsub",children:(0,n.jsxs)(e.span,{className:"vlist-t vlist-t2",children:[(0,n.jsxs)(e.span,{className:"vlist-r",children:[(0,n.jsx)(e.span,{className:"vlist",style:{height:"0.3117em"},children:(0,n.jsxs)(e.span,{style:{top:"-2.55em",marginLeft:"-0.1389em",marginRight:"0.05em"},children:[(0,n.jsx)(e.span,{className:"pstrut",style:{height:"2.7em"}}),(0,n.jsx)(e.span,{className:"sizing reset-size6 size3 mtight",children:(0,n.jsx)(e.span,{className:"mord mathnormal mtight",children:"i"})})]})}),(0,n.jsx)(e.span,{className:"vlist-s",children:"\u200b"})]}),(0,n.jsx)(e.span,{className:"vlist-r",children:(0,n.jsx)(e.span,{className:"vlist",style:{height:"0.15em"},children:(0,n.jsx)(e.span,{})})})]})})]}),(0,n.jsx)(e.span,{className:"mspace",style:{marginRight:"0.2222em"}}),(0,n.jsx)(e.span,{className:"mbin",children:"\u2212"}),(0,n.jsx)(e.span,{className:"mspace",style:{marginRight:"0.2222em"}})]}),(0,n.jsxs)(e.span,{className:"base",children:[(0,n.jsx)(e.span,{className:"strut",style:{height:"1em",verticalAlign:"-0.25em"}}),(0,n.jsxs)(e.span,{className:"mord",children:[(0,n.jsx)(e.span,{className:"mord mathnormal",children:"Q"}),(0,n.jsx)(e.span,{className:"msupsub",children:(0,n.jsxs)(e.span,{className:"vlist-t vlist-t2",children:[(0,n.jsxs)(e.span,{className:"vlist-r",children:[(0,n.jsx)(e.span,{className:"vlist",style:{height:"0.3117em"},children:(0,n.jsxs)(e.span,{style:{top:"-2.55em",marginLeft:"0em",marginRight:"0.05em"},children:[(0,n.jsx)(e.span,{className:"pstrut",style:{height:"2.7em"}}),(0,n.jsx)(e.span,{className:"sizing reset-size6 size3 mtight",children:(0,n.jsx)(e.span,{className:"mord mathnormal mtight",children:"i"})})]})}),(0,n.jsx)(e.span,{className:"vlist-s",children:"\u200b"})]}),(0,n.jsx)(e.span,{className:"vlist-r",children:(0,n.jsx)(e.span,{className:"vlist",style:{height:"0.15em"},children:(0,n.jsx)(e.span,{})})})]})})]}),(0,n.jsx)(e.span,{className:"mspace",style:{marginRight:"0.2778em"}}),(0,n.jsx)(e.span,{className:"mrel",children:"\u2223"})]})]})]})]}),"\n"]}),"\n",(0,n.jsxs)(e.li,{children:["\n",(0,n.jsxs)(e.p,{children:[(0,n.jsx)(e.strong,{children:"Sum of positive differences:"})," Add only the values where one distribution (e.g. P_i) is greater than the other (e.g. Q_i) . This essentially sums the excessive probabilities in one distribution over the other. ",(0,n.jsx)(e.br,{}),"\n",(0,n.jsxs)(e.span,{className:"katex",children:[(0,n.jsx)(e.span,{className:"katex-mathml",children:(0,n.jsx)(e.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,n.jsxs)(e.semantics,{children:[(0,n.jsxs)(e.mrow,{children:[(0,n.jsx)(e.mtext,{children:"TVD"}),(0,n.jsx)(e.mo,{children:"="}),(0,n.jsx)(e.mo,{children:"\u2211"}),(0,n.jsx)(e.mi,{children:"m"}),(0,n.jsx)(e.mi,{children:"a"}),(0,n.jsx)(e.mi,{children:"x"}),(0,n.jsx)(e.mo,{stretchy:"false",children:"("}),(0,n.jsxs)(e.msub,{children:[(0,n.jsx)(e.mi,{children:"P"}),(0,n.jsx)(e.mi,{children:"i"})]}),(0,n.jsx)(e.mo,{children:"\u2212"}),(0,n.jsxs)(e.msub,{children:[(0,n.jsx)(e.mi,{children:"Q"}),(0,n.jsx)(e.mi,{children:"i"})]}),(0,n.jsx)(e.mo,{separator:"true",children:","}),(0,n.jsx)(e.mn,{children:"0"}),(0,n.jsx)(e.mo,{stretchy:"false",children:")"})]}),(0,n.jsx)(e.annotation,{encoding:"application/x-tex",children:"\\text{TVD}=\\sum max(P_i-Q_i,0)"})]})})}),(0,n.jsxs)(e.span,{className:"katex-html","aria-hidden":"true",children:[(0,n.jsxs)(e.span,{className:"base",children:[(0,n.jsx)(e.span,{className:"strut",style:{height:"0.6833em"}}),(0,n.jsx)(e.span,{className:"mord text",children:(0,n.jsx)(e.span,{className:"mord",children:"TVD"})}),(0,n.jsx)(e.span,{className:"mspace",style:{marginRight:"0.2778em"}}),(0,n.jsx)(e.span,{className:"mrel",children:"="}),(0,n.jsx)(e.span,{className:"mspace",style:{marginRight:"0.2778em"}})]}),(0,n.jsxs)(e.span,{className:"base",children:[(0,n.jsx)(e.span,{className:"strut",style:{height:"1em",verticalAlign:"-0.25em"}}),(0,n.jsx)(e.span,{className:"mop op-symbol small-op",style:{position:"relative",top:"0em"},children:"\u2211"}),(0,n.jsx)(e.span,{className:"mspace",style:{marginRight:"0.1667em"}}),(0,n.jsx)(e.span,{className:"mord mathnormal",children:"ma"}),(0,n.jsx)(e.span,{className:"mord mathnormal",children:"x"}),(0,n.jsx)(e.span,{className:"mopen",children:"("}),(0,n.jsxs)(e.span,{className:"mord",children:[(0,n.jsx)(e.span,{className:"mord mathnormal",style:{marginRight:"0.13889em"},children:"P"}),(0,n.jsx)(e.span,{className:"msupsub",children:(0,n.jsxs)(e.span,{className:"vlist-t vlist-t2",children:[(0,n.jsxs)(e.span,{className:"vlist-r",children:[(0,n.jsx)(e.span,{className:"vlist",style:{height:"0.3117em"},children:(0,n.jsxs)(e.span,{style:{top:"-2.55em",marginLeft:"-0.1389em",marginRight:"0.05em"},children:[(0,n.jsx)(e.span,{className:"pstrut",style:{height:"2.7em"}}),(0,n.jsx)(e.span,{className:"sizing reset-size6 size3 mtight",children:(0,n.jsx)(e.span,{className:"mord mathnormal mtight",children:"i"})})]})}),(0,n.jsx)(e.span,{className:"vlist-s",children:"\u200b"})]}),(0,n.jsx)(e.span,{className:"vlist-r",children:(0,n.jsx)(e.span,{className:"vlist",style:{height:"0.15em"},children:(0,n.jsx)(e.span,{})})})]})})]}),(0,n.jsx)(e.span,{className:"mspace",style:{marginRight:"0.2222em"}}),(0,n.jsx)(e.span,{className:"mbin",children:"\u2212"}),(0,n.jsx)(e.span,{className:"mspace",style:{marginRight:"0.2222em"}})]}),(0,n.jsxs)(e.span,{className:"base",children:[(0,n.jsx)(e.span,{className:"strut",style:{height:"1em",verticalAlign:"-0.25em"}}),(0,n.jsxs)(e.span,{className:"mord",children:[(0,n.jsx)(e.span,{className:"mord mathnormal",children:"Q"}),(0,n.jsx)(e.span,{className:"msupsub",children:(0,n.jsxs)(e.span,{className:"vlist-t vlist-t2",children:[(0,n.jsxs)(e.span,{className:"vlist-r",children:[(0,n.jsx)(e.span,{className:"vlist",style:{height:"0.3117em"},children:(0,n.jsxs)(e.span,{style:{top:"-2.55em",marginLeft:"0em",marginRight:"0.05em"},children:[(0,n.jsx)(e.span,{className:"pstrut",style:{height:"2.7em"}}),(0,n.jsx)(e.span,{className:"sizing reset-size6 size3 mtight",children:(0,n.jsx)(e.span,{className:"mord mathnormal mtight",children:"i"})})]})}),(0,n.jsx)(e.span,{className:"vlist-s",children:"\u200b"})]}),(0,n.jsx)(e.span,{className:"vlist-r",children:(0,n.jsx)(e.span,{className:"vlist",style:{height:"0.15em"},children:(0,n.jsx)(e.span,{})})})]})})]}),(0,n.jsx)(e.span,{className:"mpunct",children:","}),(0,n.jsx)(e.span,{className:"mspace",style:{marginRight:"0.1667em"}}),(0,n.jsx)(e.span,{className:"mord",children:"0"}),(0,n.jsx)(e.span,{className:"mclose",children:")"})]})]})]})]}),"\n"]}),"\n"]}),(0,n.jsx)(e.p,{children:"to do: replace formula with example DataFrame visualization"}),(0,n.jsxs)(e.ol,{start:"3",children:["\n",(0,n.jsxs)(e.li,{children:[(0,n.jsx)(e.strong,{children:"Sum of negative differences:"})," Add only the absolute values where the selected distribution (e.g. P_i) is less than the other (e.g. Q_i). This essentially sums the deficient probabilities in one distribution relative to the other. ",(0,n.jsx)(e.br,{}),"\n",(0,n.jsxs)(e.span,{className:"katex",children:[(0,n.jsx)(e.span,{className:"katex-mathml",children:(0,n.jsx)(e.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,n.jsxs)(e.semantics,{children:[(0,n.jsxs)(e.mrow,{children:[(0,n.jsx)(e.mtext,{children:"TVD"}),(0,n.jsx)(e.mo,{children:"="}),(0,n.jsx)(e.mo,{children:"\u2211"}),(0,n.jsx)(e.mi,{children:"a"}),(0,n.jsx)(e.mi,{children:"b"}),(0,n.jsx)(e.mi,{children:"s"}),(0,n.jsx)(e.mo,{stretchy:"false",children:"("}),(0,n.jsx)(e.mi,{children:"m"}),(0,n.jsx)(e.mi,{children:"i"}),(0,n.jsx)(e.mi,{children:"n"}),(0,n.jsx)(e.mo,{stretchy:"false",children:"("}),(0,n.jsxs)(e.msub,{children:[(0,n.jsx)(e.mi,{children:"P"}),(0,n.jsx)(e.mi,{children:"i"})]}),(0,n.jsx)(e.mo,{children:"\u2212"}),(0,n.jsxs)(e.msub,{children:[(0,n.jsx)(e.mi,{children:"Q"}),(0,n.jsx)(e.mi,{children:"i"})]}),(0,n.jsx)(e.mo,{separator:"true",children:","}),(0,n.jsx)(e.mn,{children:"0"}),(0,n.jsx)(e.mo,{stretchy:"false",children:")"}),(0,n.jsx)(e.mo,{stretchy:"false",children:")"}),(0,n.jsx)(e.mtext,{children:"\xa0or\xa0TVD"}),(0,n.jsx)(e.mo,{children:"="}),(0,n.jsx)(e.mo,{children:"\u2211"}),(0,n.jsx)(e.mi,{children:"m"}),(0,n.jsx)(e.mi,{children:"a"}),(0,n.jsx)(e.mi,{children:"x"}),(0,n.jsx)(e.mo,{stretchy:"false",children:"("}),(0,n.jsxs)(e.msub,{children:[(0,n.jsx)(e.mi,{children:"Q"}),(0,n.jsx)(e.mi,{children:"i"})]}),(0,n.jsx)(e.mo,{children:"\u2212"}),(0,n.jsxs)(e.msub,{children:[(0,n.jsx)(e.mi,{children:"P"}),(0,n.jsx)(e.mi,{children:"i"})]}),(0,n.jsx)(e.mo,{separator:"true",children:","}),(0,n.jsx)(e.mn,{children:"0"}),(0,n.jsx)(e.mo,{stretchy:"false",children:")"})]}),(0,n.jsx)(e.annotation,{encoding:"application/x-tex",children:"\\text{TVD}=\\sum abs(min(P_i-Q_i,0)) \\ \\text{or} \\ \\text{TVD}=\\sum max(Q_i-P_i,0)"})]})})}),(0,n.jsxs)(e.span,{className:"katex-html","aria-hidden":"true",children:[(0,n.jsxs)(e.span,{className:"base",children:[(0,n.jsx)(e.span,{className:"strut",style:{height:"0.6833em"}}),(0,n.jsx)(e.span,{className:"mord text",children:(0,n.jsx)(e.span,{className:"mord",children:"TVD"})}),(0,n.jsx)(e.span,{className:"mspace",style:{marginRight:"0.2778em"}}),(0,n.jsx)(e.span,{className:"mrel",children:"="}),(0,n.jsx)(e.span,{className:"mspace",style:{marginRight:"0.2778em"}})]}),(0,n.jsxs)(e.span,{className:"base",children:[(0,n.jsx)(e.span,{className:"strut",style:{height:"1em",verticalAlign:"-0.25em"}}),(0,n.jsx)(e.span,{className:"mop op-symbol small-op",style:{position:"relative",top:"0em"},children:"\u2211"}),(0,n.jsx)(e.span,{className:"mspace",style:{marginRight:"0.1667em"}}),(0,n.jsx)(e.span,{className:"mord mathnormal",children:"ab"}),(0,n.jsx)(e.span,{className:"mord mathnormal",children:"s"}),(0,n.jsx)(e.span,{className:"mopen",children:"("}),(0,n.jsx)(e.span,{className:"mord mathnormal",children:"min"}),(0,n.jsx)(e.span,{className:"mopen",children:"("}),(0,n.jsxs)(e.span,{className:"mord",children:[(0,n.jsx)(e.span,{className:"mord mathnormal",style:{marginRight:"0.13889em"},children:"P"}),(0,n.jsx)(e.span,{className:"msupsub",children:(0,n.jsxs)(e.span,{className:"vlist-t vlist-t2",children:[(0,n.jsxs)(e.span,{className:"vlist-r",children:[(0,n.jsx)(e.span,{className:"vlist",style:{height:"0.3117em"},children:(0,n.jsxs)(e.span,{style:{top:"-2.55em",marginLeft:"-0.1389em",marginRight:"0.05em"},children:[(0,n.jsx)(e.span,{className:"pstrut",style:{height:"2.7em"}}),(0,n.jsx)(e.span,{className:"sizing reset-size6 size3 mtight",children:(0,n.jsx)(e.span,{className:"mord mathnormal mtight",children:"i"})})]})}),(0,n.jsx)(e.span,{className:"vlist-s",children:"\u200b"})]}),(0,n.jsx)(e.span,{className:"vlist-r",children:(0,n.jsx)(e.span,{className:"vlist",style:{height:"0.15em"},children:(0,n.jsx)(e.span,{})})})]})})]}),(0,n.jsx)(e.span,{className:"mspace",style:{marginRight:"0.2222em"}}),(0,n.jsx)(e.span,{className:"mbin",children:"\u2212"}),(0,n.jsx)(e.span,{className:"mspace",style:{marginRight:"0.2222em"}})]}),(0,n.jsxs)(e.span,{className:"base",children:[(0,n.jsx)(e.span,{className:"strut",style:{height:"1em",verticalAlign:"-0.25em"}}),(0,n.jsxs)(e.span,{className:"mord",children:[(0,n.jsx)(e.span,{className:"mord mathnormal",children:"Q"}),(0,n.jsx)(e.span,{className:"msupsub",children:(0,n.jsxs)(e.span,{className:"vlist-t vlist-t2",children:[(0,n.jsxs)(e.span,{className:"vlist-r",children:[(0,n.jsx)(e.span,{className:"vlist",style:{height:"0.3117em"},children:(0,n.jsxs)(e.span,{style:{top:"-2.55em",marginLeft:"0em",marginRight:"0.05em"},children:[(0,n.jsx)(e.span,{className:"pstrut",style:{height:"2.7em"}}),(0,n.jsx)(e.span,{className:"sizing reset-size6 size3 mtight",children:(0,n.jsx)(e.span,{className:"mord mathnormal mtight",children:"i"})})]})}),(0,n.jsx)(e.span,{className:"vlist-s",children:"\u200b"})]}),(0,n.jsx)(e.span,{className:"vlist-r",children:(0,n.jsx)(e.span,{className:"vlist",style:{height:"0.15em"},children:(0,n.jsx)(e.span,{})})})]})})]}),(0,n.jsx)(e.span,{className:"mpunct",children:","}),(0,n.jsx)(e.span,{className:"mspace",style:{marginRight:"0.1667em"}}),(0,n.jsx)(e.span,{className:"mord",children:"0"}),(0,n.jsx)(e.span,{className:"mclose",children:"))"}),(0,n.jsx)(e.span,{className:"mspace",children:"\xa0"}),(0,n.jsx)(e.span,{className:"mord text",children:(0,n.jsx)(e.span,{className:"mord",children:"or"})}),(0,n.jsx)(e.span,{className:"mspace",children:"\xa0"}),(0,n.jsx)(e.span,{className:"mord text",children:(0,n.jsx)(e.span,{className:"mord",children:"TVD"})}),(0,n.jsx)(e.span,{className:"mspace",style:{marginRight:"0.2778em"}}),(0,n.jsx)(e.span,{className:"mrel",children:"="}),(0,n.jsx)(e.span,{className:"mspace",style:{marginRight:"0.2778em"}})]}),(0,n.jsxs)(e.span,{className:"base",children:[(0,n.jsx)(e.span,{className:"strut",style:{height:"1em",verticalAlign:"-0.25em"}}),(0,n.jsx)(e.span,{className:"mop op-symbol small-op",style:{position:"relative",top:"0em"},children:"\u2211"}),(0,n.jsx)(e.span,{className:"mspace",style:{marginRight:"0.1667em"}}),(0,n.jsx)(e.span,{className:"mord mathnormal",children:"ma"}),(0,n.jsx)(e.span,{className:"mord mathnormal",children:"x"}),(0,n.jsx)(e.span,{className:"mopen",children:"("}),(0,n.jsxs)(e.span,{className:"mord",children:[(0,n.jsx)(e.span,{className:"mord mathnormal",children:"Q"}),(0,n.jsx)(e.span,{className:"msupsub",children:(0,n.jsxs)(e.span,{className:"vlist-t vlist-t2",children:[(0,n.jsxs)(e.span,{className:"vlist-r",children:[(0,n.jsx)(e.span,{className:"vlist",style:{height:"0.3117em"},children:(0,n.jsxs)(e.span,{style:{top:"-2.55em",marginLeft:"0em",marginRight:"0.05em"},children:[(0,n.jsx)(e.span,{className:"pstrut",style:{height:"2.7em"}}),(0,n.jsx)(e.span,{className:"sizing reset-size6 size3 mtight",children:(0,n.jsx)(e.span,{className:"mord mathnormal mtight",children:"i"})})]})}),(0,n.jsx)(e.span,{className:"vlist-s",children:"\u200b"})]}),(0,n.jsx)(e.span,{className:"vlist-r",children:(0,n.jsx)(e.span,{className:"vlist",style:{height:"0.15em"},children:(0,n.jsx)(e.span,{})})})]})})]}),(0,n.jsx)(e.span,{className:"mspace",style:{marginRight:"0.2222em"}}),(0,n.jsx)(e.span,{className:"mbin",children:"\u2212"}),(0,n.jsx)(e.span,{className:"mspace",style:{marginRight:"0.2222em"}})]}),(0,n.jsxs)(e.span,{className:"base",children:[(0,n.jsx)(e.span,{className:"strut",style:{height:"1em",verticalAlign:"-0.25em"}}),(0,n.jsxs)(e.span,{className:"mord",children:[(0,n.jsx)(e.span,{className:"mord mathnormal",style:{marginRight:"0.13889em"},children:"P"}),(0,n.jsx)(e.span,{className:"msupsub",children:(0,n.jsxs)(e.span,{className:"vlist-t vlist-t2",children:[(0,n.jsxs)(e.span,{className:"vlist-r",children:[(0,n.jsx)(e.span,{className:"vlist",style:{height:"0.3117em"},children:(0,n.jsxs)(e.span,{style:{top:"-2.55em",marginLeft:"-0.1389em",marginRight:"0.05em"},children:[(0,n.jsx)(e.span,{className:"pstrut",style:{height:"2.7em"}}),(0,n.jsx)(e.span,{className:"sizing reset-size6 size3 mtight",children:(0,n.jsx)(e.span,{className:"mord mathnormal mtight",children:"i"})})]})}),(0,n.jsx)(e.span,{className:"vlist-s",children:"\u200b"})]}),(0,n.jsx)(e.span,{className:"vlist-r",children:(0,n.jsx)(e.span,{className:"vlist",style:{height:"0.15em"},children:(0,n.jsx)(e.span,{})})})]})})]}),(0,n.jsx)(e.span,{className:"mpunct",children:","}),(0,n.jsx)(e.span,{className:"mspace",style:{marginRight:"0.1667em"}}),(0,n.jsx)(e.span,{className:"mord",children:"0"}),(0,n.jsx)(e.span,{className:"mclose",children:")"})]})]})]})]}),"\n"]}),(0,n.jsx)(e.p,{children:"to do: replace formula with example DataFrame visualization"})]})]})}function d(s={}){const{wrapper:e}={...(0,i.R)(),...s.components};return e?(0,n.jsx)(e,{...s,children:(0,n.jsx)(h,{...s})}):h(s)}},8597:(s,e,a)=>{a.d(e,{A:()=>i});a(6540);var n=a(4848);const i=s=>{let{data:e}=s,a=[],i=[],t="",l=[];if(e){const s=JSON.parse(e);a=s.columns||[],i=s.data||[],t=s.indexName||"Index",l=s.index||[]}return(0,n.jsx)("div",{className:"dataframe-container",children:(0,n.jsxs)("table",{className:"dataframe-table",children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{children:t}),a.map(((s,e)=>(0,n.jsx)("th",{children:s},e)))]})}),(0,n.jsx)("tbody",{children:i.map(((s,e)=>(0,n.jsxs)("tr",{children:[(0,n.jsx)("td",{className:"index-value",children:l[e]}),s.map(((s,e)=>{return(0,n.jsx)("td",{children:(a=s,"boolean"==typeof a?a.toString().charAt(0).toUpperCase()+a.toString().slice(1):a)},e);var a}))]},e)))})]})})}},5158:(s,e,a)=>{a.d(e,{A:()=>t});var n=a(6540),i=a(4848);const t=function(s){let{src:e,sourceLink:a,aspectRatio:t=16/9}=s;const[l,r]=(0,n.useState)(0),[c,m]=(0,n.useState)(0),h=(0,n.useRef)(null);return(0,n.useEffect)((()=>{const s=()=>{if(h.current){const s=h.current.offsetWidth;m(s/t)}};return s(),window.addEventListener("resize",s),()=>window.removeEventListener("resize",s)}),[t]),(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("div",{ref:h,style:{width:"100%",position:"relative",maxWidth:"100%",backgroundColor:"white"},children:(0,i.jsx)("iframe",{src:e,style:{width:"100%",height:`${c}px`,border:"0",allowFullScreen:!0}},l)}),(0,i.jsx)("div",{style:{display:"flex",justifyContent:"center",margin:"20px 0"},children:(0,i.jsx)("a",{href:a,target:"_blank",rel:"noopener noreferrer",children:"(Source)"})}),(0,i.jsx)("div",{style:{display:"flex",justifyContent:"center",margin:"10px 0"},children:(0,i.jsx)("button",{onClick:()=>{r((s=>s+1))},style:{backgroundColor:"#4CAF50",color:"white",padding:"10px 20px",border:"none",borderRadius:"5px",cursor:"pointer",outline:"none",fontSize:"16px",fontWeight:"bold",boxShadow:"0 4px 8px rgba(0,0,0,0.1)",transition:"background-color 0.3s"},onMouseOver:s=>s.currentTarget.style.backgroundColor="#45a049",onMouseOut:s=>s.currentTarget.style.backgroundColor="#4CAF50",children:"Restart Diagram"})})]})}},8453:(s,e,a)=>{a.d(e,{R:()=>l,x:()=>r});var n=a(6540);const i={},t=n.createContext(i);function l(s){const e=n.useContext(t);return n.useMemo((function(){return"function"==typeof s?s(e):{...e,...s}}),[e,s])}function r(s){let e;return e=s.disableParentContext?"function"==typeof s.components?s.components(i):s.components||i:l(s.components),n.createElement(t.Provider,{value:e},s.children)}}}]); \ No newline at end of file diff --git a/assets/js/60c4aef6.bacecd71.js b/assets/js/60c4aef6.bacecd71.js deleted file mode 100644 index eae97735..00000000 --- a/assets/js/60c4aef6.bacecd71.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunkbpd_reference=self.webpackChunkbpd_reference||[]).push([[6142],{3071:(s,e,a)=>{a.r(e),a.d(e,{assets:()=>c,contentTitle:()=>l,default:()=>d,frontMatter:()=>t,metadata:()=>r,toc:()=>m});var n=a(4848),i=a(8453);a(8597),a(5158);const t={sidebar_position:4,sidebar_label:"Observed & Test Statistic",title:"Observed & Test Statistic"},l=void 0,r={id:"statistical-inference/obs_and_test_stats",title:"Observed & Test Statistic",description:"Concept",source:"@site/docs/statistical-inference/obs_and_test_stats.md",sourceDirName:"statistical-inference",slug:"/statistical-inference/obs_and_test_stats",permalink:"/bpd-reference/docs/statistical-inference/obs_and_test_stats",draft:!1,unlisted:!1,editUrl:"https://github.com/dsc-courses/bpd-reference/tree/main/docs/statistical-inference/obs_and_test_stats.md",tags:[],version:"current",sidebarPosition:4,frontMatter:{sidebar_position:4,sidebar_label:"Observed & Test Statistic",title:"Observed & Test Statistic"},sidebar:"statsSidebar",previous:{title:"Null & Alternative Hypothesis",permalink:"/bpd-reference/docs/statistical-inference/null_and_alt"},next:{title:"P-value",permalink:"/bpd-reference/docs/statistical-inference/p_value"}},c={},m=[{value:"Concept",id:"concept",level:2},{value:"Common Test Statistics \ud83c\udf1f",id:"common-test-statistics-",level:2},{value:"1. Absolute Difference",id:"1-absolute-difference",level:3},{value:"2. Difference",id:"2-difference",level:3},{value:"3. Total Variation Distance (TVD)",id:"3-total-variation-distance-tvd",level:3}];function h(s){const e={admonition:"admonition",annotation:"annotation",br:"br",code:"code",em:"em",h2:"h2",h3:"h3",li:"li",math:"math",mfrac:"mfrac",mi:"mi",mn:"mn",mo:"mo",mrow:"mrow",msub:"msub",mtext:"mtext",ol:"ol",p:"p",pre:"pre",semantics:"semantics",span:"span",strong:"strong",ul:"ul",...(0,i.R)(),...s.components};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(e.h2,{id:"concept",children:"Concept"}),"\n",(0,n.jsxs)(e.admonition,{title:"Terminology",type:"info",children:[(0,n.jsxs)(e.p,{children:[(0,n.jsx)(e.strong,{children:"Experiment"}),": A process whose outcome is random."]}),(0,n.jsxs)(e.ul,{children:["\n",(0,n.jsx)(e.li,{children:"Example: Flipping 100 coins."}),"\n"]}),(0,n.jsxs)(e.p,{children:[(0,n.jsx)(e.strong,{children:"Observed Statistic"}),": A statistic computed from the observed data."]}),(0,n.jsxs)(e.ul,{children:["\n",(0,n.jsx)(e.li,{children:"Example: The number of heads observed."}),"\n"]}),(0,n.jsxs)(e.p,{children:[(0,n.jsx)(e.strong,{children:"Test Statistic"}),": A statistic computed from a sample generated under the assumption that the null hypothesis is true."]}),(0,n.jsxs)(e.ul,{children:["\n",(0,n.jsx)(e.li,{children:"Think of the test statistic a number you write down each time you perform an experiment."}),"\n",(0,n.jsx)(e.li,{children:"The test statistic should be such that high observed values lean towards one hypothesis and low observed values lean towards the other."}),"\n"]})]}),"\n",(0,n.jsx)(e.h2,{id:"common-test-statistics-",children:"Common Test Statistics \ud83c\udf1f"}),"\n",(0,n.jsx)(e.h3,{id:"1-absolute-difference",children:"1. Absolute Difference"}),"\n",(0,n.jsx)(e.p,{children:"Absolute difference in group mean/median/number of times a certain event happens."}),"\n",(0,n.jsxs)(e.ul,{children:["\n",(0,n.jsxs)(e.li,{children:["\u2705 Used for measuring how different two ",(0,n.jsx)(e.strong,{children:"numerical distributions"})," are, and when the alternative hypothesis is ",(0,n.jsx)(e.strong,{children:(0,n.jsx)(e.em,{children:"not equal to"})}),'. For example, "the coin is biased" or "the probability of tossing a head is 0.5".']}),"\n"]}),"\n",(0,n.jsx)(e.h3,{id:"2-difference",children:"2. Difference"}),"\n",(0,n.jsx)(e.p,{children:"Difference in group mean/median/number of times a certain event happens."}),"\n",(0,n.jsxs)(e.ul,{children:["\n",(0,n.jsxs)(e.li,{children:["\u2705 Used for measuring how different two ",(0,n.jsx)(e.strong,{children:"numerical distributions"})," are, and the alternative hypothesis is ",(0,n.jsx)(e.strong,{children:(0,n.jsx)(e.em,{children:"less than"})})," or ",(0,n.jsx)(e.strong,{children:(0,n.jsx)(e.em,{children:"greater than"})}),'. For example, "the coin is biased towards heads" or "the probability of tossing a head is greater then 0.5".']}),"\n"]}),"\n",(0,n.jsx)(e.h3,{id:"3-total-variation-distance-tvd",children:"3. Total Variation Distance (TVD)"}),"\n",(0,n.jsxs)(e.p,{children:["A test statistic that quantifies how different ",(0,n.jsx)(e.strong,{children:"two categorical distributions"})," are by calculating the sum of the absolute differences of their proportions, all divided by 2."]}),"\n",(0,n.jsxs)(e.ul,{children:["\n",(0,n.jsx)(e.li,{children:"\u274c\ufe0f The TVD is not used for permutation tests."}),"\n",(0,n.jsxs)(e.li,{children:['\u2705 Used for assessing whether an "observed sample" was drawn randomly from a known ',(0,n.jsx)(e.strong,{children:"categorical distribution"}),"."]}),"\n"]}),"\n",(0,n.jsx)(e.pre,{children:(0,n.jsx)(e.code,{className:"language-python",children:"#code implementation\ndef tvd(dist1, dist2):\n return np.abs(dist1 - dist2).sum() / 2\n"})}),"\n",(0,n.jsxs)(e.admonition,{type:"note",children:[(0,n.jsxs)(e.p,{children:[(0,n.jsx)(e.strong,{children:"3 Ways of Computing TVD:"})," \ud83e\uddee",(0,n.jsx)(e.br,{}),"\n","to do: use an example\n",(0,n.jsxs)(e.em,{children:["Assume ",(0,n.jsxs)(e.span,{className:"katex",children:[(0,n.jsx)(e.span,{className:"katex-mathml",children:(0,n.jsx)(e.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,n.jsxs)(e.semantics,{children:[(0,n.jsx)(e.mrow,{children:(0,n.jsxs)(e.msub,{children:[(0,n.jsx)(e.mi,{children:"P"}),(0,n.jsx)(e.mi,{children:"i"})]})}),(0,n.jsx)(e.annotation,{encoding:"application/x-tex",children:"P_i"})]})})}),(0,n.jsx)(e.span,{className:"katex-html","aria-hidden":"true",children:(0,n.jsxs)(e.span,{className:"base",children:[(0,n.jsx)(e.span,{className:"strut",style:{height:"0.8333em",verticalAlign:"-0.15em"}}),(0,n.jsxs)(e.span,{className:"mord",children:[(0,n.jsx)(e.span,{className:"mord mathnormal",style:{marginRight:"0.13889em"},children:"P"}),(0,n.jsx)(e.span,{className:"msupsub",children:(0,n.jsxs)(e.span,{className:"vlist-t vlist-t2",children:[(0,n.jsxs)(e.span,{className:"vlist-r",children:[(0,n.jsx)(e.span,{className:"vlist",style:{height:"0.3117em"},children:(0,n.jsxs)(e.span,{style:{top:"-2.55em",marginLeft:"-0.1389em",marginRight:"0.05em"},children:[(0,n.jsx)(e.span,{className:"pstrut",style:{height:"2.7em"}}),(0,n.jsx)(e.span,{className:"sizing reset-size6 size3 mtight",children:(0,n.jsx)(e.span,{className:"mord mathnormal mtight",children:"i"})})]})}),(0,n.jsx)(e.span,{className:"vlist-s",children:"\u200b"})]}),(0,n.jsx)(e.span,{className:"vlist-r",children:(0,n.jsx)(e.span,{className:"vlist",style:{height:"0.15em"},children:(0,n.jsx)(e.span,{})})})]})})]})]})})]})," is one distribution and ",(0,n.jsxs)(e.span,{className:"katex",children:[(0,n.jsx)(e.span,{className:"katex-mathml",children:(0,n.jsx)(e.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,n.jsxs)(e.semantics,{children:[(0,n.jsx)(e.mrow,{children:(0,n.jsxs)(e.msub,{children:[(0,n.jsx)(e.mi,{children:"Q"}),(0,n.jsx)(e.mi,{children:"i"})]})}),(0,n.jsx)(e.annotation,{encoding:"application/x-tex",children:"Q_i"})]})})}),(0,n.jsx)(e.span,{className:"katex-html","aria-hidden":"true",children:(0,n.jsxs)(e.span,{className:"base",children:[(0,n.jsx)(e.span,{className:"strut",style:{height:"0.8778em",verticalAlign:"-0.1944em"}}),(0,n.jsxs)(e.span,{className:"mord",children:[(0,n.jsx)(e.span,{className:"mord mathnormal",children:"Q"}),(0,n.jsx)(e.span,{className:"msupsub",children:(0,n.jsxs)(e.span,{className:"vlist-t vlist-t2",children:[(0,n.jsxs)(e.span,{className:"vlist-r",children:[(0,n.jsx)(e.span,{className:"vlist",style:{height:"0.3117em"},children:(0,n.jsxs)(e.span,{style:{top:"-2.55em",marginLeft:"0em",marginRight:"0.05em"},children:[(0,n.jsx)(e.span,{className:"pstrut",style:{height:"2.7em"}}),(0,n.jsx)(e.span,{className:"sizing reset-size6 size3 mtight",children:(0,n.jsx)(e.span,{className:"mord mathnormal mtight",children:"i"})})]})}),(0,n.jsx)(e.span,{className:"vlist-s",children:"\u200b"})]}),(0,n.jsx)(e.span,{className:"vlist-r",children:(0,n.jsx)(e.span,{className:"vlist",style:{height:"0.15em"},children:(0,n.jsx)(e.span,{})})})]})})]})]})})]})," is the other."]})]}),(0,n.jsxs)(e.ol,{children:["\n",(0,n.jsxs)(e.li,{children:["\n",(0,n.jsxs)(e.p,{children:[(0,n.jsx)(e.strong,{children:"Follow the definition:"})," Calculate the sum of the absolute differences of the two distributions' proportions, all divided by 2. ",(0,n.jsx)(e.br,{}),"\n",(0,n.jsxs)(e.span,{className:"katex",children:[(0,n.jsx)(e.span,{className:"katex-mathml",children:(0,n.jsx)(e.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,n.jsxs)(e.semantics,{children:[(0,n.jsxs)(e.mrow,{children:[(0,n.jsx)(e.mtext,{children:"TVD"}),(0,n.jsx)(e.mo,{children:"="}),(0,n.jsxs)(e.mfrac,{children:[(0,n.jsx)(e.mn,{children:"1"}),(0,n.jsx)(e.mn,{children:"2"})]}),(0,n.jsx)(e.mo,{children:"\u2211"}),(0,n.jsx)(e.mo,{children:"\u2223"}),(0,n.jsxs)(e.msub,{children:[(0,n.jsx)(e.mi,{children:"P"}),(0,n.jsx)(e.mi,{children:"i"})]}),(0,n.jsx)(e.mo,{children:"\u2212"}),(0,n.jsxs)(e.msub,{children:[(0,n.jsx)(e.mi,{children:"Q"}),(0,n.jsx)(e.mi,{children:"i"})]}),(0,n.jsx)(e.mo,{children:"\u2223"})]}),(0,n.jsx)(e.annotation,{encoding:"application/x-tex",children:"\\text{TVD}=\\frac{1}{2}\\sum \\mid P_i - Q_i\\mid"})]})})}),(0,n.jsxs)(e.span,{className:"katex-html","aria-hidden":"true",children:[(0,n.jsxs)(e.span,{className:"base",children:[(0,n.jsx)(e.span,{className:"strut",style:{height:"0.6833em"}}),(0,n.jsx)(e.span,{className:"mord text",children:(0,n.jsx)(e.span,{className:"mord",children:"TVD"})}),(0,n.jsx)(e.span,{className:"mspace",style:{marginRight:"0.2778em"}}),(0,n.jsx)(e.span,{className:"mrel",children:"="}),(0,n.jsx)(e.span,{className:"mspace",style:{marginRight:"0.2778em"}})]}),(0,n.jsxs)(e.span,{className:"base",children:[(0,n.jsx)(e.span,{className:"strut",style:{height:"1.1901em",verticalAlign:"-0.345em"}}),(0,n.jsxs)(e.span,{className:"mord",children:[(0,n.jsx)(e.span,{className:"mopen nulldelimiter"}),(0,n.jsx)(e.span,{className:"mfrac",children:(0,n.jsxs)(e.span,{className:"vlist-t vlist-t2",children:[(0,n.jsxs)(e.span,{className:"vlist-r",children:[(0,n.jsxs)(e.span,{className:"vlist",style:{height:"0.8451em"},children:[(0,n.jsxs)(e.span,{style:{top:"-2.655em"},children:[(0,n.jsx)(e.span,{className:"pstrut",style:{height:"3em"}}),(0,n.jsx)(e.span,{className:"sizing reset-size6 size3 mtight",children:(0,n.jsx)(e.span,{className:"mord mtight",children:(0,n.jsx)(e.span,{className:"mord mtight",children:"2"})})})]}),(0,n.jsxs)(e.span,{style:{top:"-3.23em"},children:[(0,n.jsx)(e.span,{className:"pstrut",style:{height:"3em"}}),(0,n.jsx)(e.span,{className:"frac-line",style:{borderBottomWidth:"0.04em"}})]}),(0,n.jsxs)(e.span,{style:{top:"-3.394em"},children:[(0,n.jsx)(e.span,{className:"pstrut",style:{height:"3em"}}),(0,n.jsx)(e.span,{className:"sizing reset-size6 size3 mtight",children:(0,n.jsx)(e.span,{className:"mord mtight",children:(0,n.jsx)(e.span,{className:"mord mtight",children:"1"})})})]})]}),(0,n.jsx)(e.span,{className:"vlist-s",children:"\u200b"})]}),(0,n.jsx)(e.span,{className:"vlist-r",children:(0,n.jsx)(e.span,{className:"vlist",style:{height:"0.345em"},children:(0,n.jsx)(e.span,{})})})]})}),(0,n.jsx)(e.span,{className:"mclose nulldelimiter"})]}),(0,n.jsx)(e.span,{className:"mspace",style:{marginRight:"0.1667em"}}),(0,n.jsx)(e.span,{className:"mop op-symbol small-op",style:{position:"relative",top:"0em"},children:"\u2211"}),(0,n.jsx)(e.span,{className:"mspace",style:{marginRight:"0.2778em"}}),(0,n.jsx)(e.span,{className:"mrel",children:"\u2223"}),(0,n.jsx)(e.span,{className:"mspace",style:{marginRight:"0.2778em"}})]}),(0,n.jsxs)(e.span,{className:"base",children:[(0,n.jsx)(e.span,{className:"strut",style:{height:"0.8333em",verticalAlign:"-0.15em"}}),(0,n.jsxs)(e.span,{className:"mord",children:[(0,n.jsx)(e.span,{className:"mord mathnormal",style:{marginRight:"0.13889em"},children:"P"}),(0,n.jsx)(e.span,{className:"msupsub",children:(0,n.jsxs)(e.span,{className:"vlist-t vlist-t2",children:[(0,n.jsxs)(e.span,{className:"vlist-r",children:[(0,n.jsx)(e.span,{className:"vlist",style:{height:"0.3117em"},children:(0,n.jsxs)(e.span,{style:{top:"-2.55em",marginLeft:"-0.1389em",marginRight:"0.05em"},children:[(0,n.jsx)(e.span,{className:"pstrut",style:{height:"2.7em"}}),(0,n.jsx)(e.span,{className:"sizing reset-size6 size3 mtight",children:(0,n.jsx)(e.span,{className:"mord mathnormal mtight",children:"i"})})]})}),(0,n.jsx)(e.span,{className:"vlist-s",children:"\u200b"})]}),(0,n.jsx)(e.span,{className:"vlist-r",children:(0,n.jsx)(e.span,{className:"vlist",style:{height:"0.15em"},children:(0,n.jsx)(e.span,{})})})]})})]}),(0,n.jsx)(e.span,{className:"mspace",style:{marginRight:"0.2222em"}}),(0,n.jsx)(e.span,{className:"mbin",children:"\u2212"}),(0,n.jsx)(e.span,{className:"mspace",style:{marginRight:"0.2222em"}})]}),(0,n.jsxs)(e.span,{className:"base",children:[(0,n.jsx)(e.span,{className:"strut",style:{height:"1em",verticalAlign:"-0.25em"}}),(0,n.jsxs)(e.span,{className:"mord",children:[(0,n.jsx)(e.span,{className:"mord mathnormal",children:"Q"}),(0,n.jsx)(e.span,{className:"msupsub",children:(0,n.jsxs)(e.span,{className:"vlist-t vlist-t2",children:[(0,n.jsxs)(e.span,{className:"vlist-r",children:[(0,n.jsx)(e.span,{className:"vlist",style:{height:"0.3117em"},children:(0,n.jsxs)(e.span,{style:{top:"-2.55em",marginLeft:"0em",marginRight:"0.05em"},children:[(0,n.jsx)(e.span,{className:"pstrut",style:{height:"2.7em"}}),(0,n.jsx)(e.span,{className:"sizing reset-size6 size3 mtight",children:(0,n.jsx)(e.span,{className:"mord mathnormal mtight",children:"i"})})]})}),(0,n.jsx)(e.span,{className:"vlist-s",children:"\u200b"})]}),(0,n.jsx)(e.span,{className:"vlist-r",children:(0,n.jsx)(e.span,{className:"vlist",style:{height:"0.15em"},children:(0,n.jsx)(e.span,{})})})]})})]}),(0,n.jsx)(e.span,{className:"mspace",style:{marginRight:"0.2778em"}}),(0,n.jsx)(e.span,{className:"mrel",children:"\u2223"})]})]})]})]}),"\n"]}),"\n",(0,n.jsxs)(e.li,{children:["\n",(0,n.jsxs)(e.p,{children:[(0,n.jsx)(e.strong,{children:"Sum of positive differences:"})," Add only the values where one distribution (e.g. P_i) is greater than the other (e.g. Q_i) . This essentially sums the excessive probabilities in one distribution over the other. ",(0,n.jsx)(e.br,{}),"\n",(0,n.jsxs)(e.span,{className:"katex",children:[(0,n.jsx)(e.span,{className:"katex-mathml",children:(0,n.jsx)(e.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,n.jsxs)(e.semantics,{children:[(0,n.jsxs)(e.mrow,{children:[(0,n.jsx)(e.mtext,{children:"TVD"}),(0,n.jsx)(e.mo,{children:"="}),(0,n.jsx)(e.mo,{children:"\u2211"}),(0,n.jsx)(e.mi,{children:"m"}),(0,n.jsx)(e.mi,{children:"a"}),(0,n.jsx)(e.mi,{children:"x"}),(0,n.jsx)(e.mo,{stretchy:"false",children:"("}),(0,n.jsxs)(e.msub,{children:[(0,n.jsx)(e.mi,{children:"P"}),(0,n.jsx)(e.mi,{children:"i"})]}),(0,n.jsx)(e.mo,{children:"\u2212"}),(0,n.jsxs)(e.msub,{children:[(0,n.jsx)(e.mi,{children:"Q"}),(0,n.jsx)(e.mi,{children:"i"})]}),(0,n.jsx)(e.mo,{separator:"true",children:","}),(0,n.jsx)(e.mn,{children:"0"}),(0,n.jsx)(e.mo,{stretchy:"false",children:")"})]}),(0,n.jsx)(e.annotation,{encoding:"application/x-tex",children:"\\text{TVD}=\\sum max(P_i-Q_i,0)"})]})})}),(0,n.jsxs)(e.span,{className:"katex-html","aria-hidden":"true",children:[(0,n.jsxs)(e.span,{className:"base",children:[(0,n.jsx)(e.span,{className:"strut",style:{height:"0.6833em"}}),(0,n.jsx)(e.span,{className:"mord text",children:(0,n.jsx)(e.span,{className:"mord",children:"TVD"})}),(0,n.jsx)(e.span,{className:"mspace",style:{marginRight:"0.2778em"}}),(0,n.jsx)(e.span,{className:"mrel",children:"="}),(0,n.jsx)(e.span,{className:"mspace",style:{marginRight:"0.2778em"}})]}),(0,n.jsxs)(e.span,{className:"base",children:[(0,n.jsx)(e.span,{className:"strut",style:{height:"1em",verticalAlign:"-0.25em"}}),(0,n.jsx)(e.span,{className:"mop op-symbol small-op",style:{position:"relative",top:"0em"},children:"\u2211"}),(0,n.jsx)(e.span,{className:"mspace",style:{marginRight:"0.1667em"}}),(0,n.jsx)(e.span,{className:"mord mathnormal",children:"ma"}),(0,n.jsx)(e.span,{className:"mord mathnormal",children:"x"}),(0,n.jsx)(e.span,{className:"mopen",children:"("}),(0,n.jsxs)(e.span,{className:"mord",children:[(0,n.jsx)(e.span,{className:"mord mathnormal",style:{marginRight:"0.13889em"},children:"P"}),(0,n.jsx)(e.span,{className:"msupsub",children:(0,n.jsxs)(e.span,{className:"vlist-t vlist-t2",children:[(0,n.jsxs)(e.span,{className:"vlist-r",children:[(0,n.jsx)(e.span,{className:"vlist",style:{height:"0.3117em"},children:(0,n.jsxs)(e.span,{style:{top:"-2.55em",marginLeft:"-0.1389em",marginRight:"0.05em"},children:[(0,n.jsx)(e.span,{className:"pstrut",style:{height:"2.7em"}}),(0,n.jsx)(e.span,{className:"sizing reset-size6 size3 mtight",children:(0,n.jsx)(e.span,{className:"mord mathnormal mtight",children:"i"})})]})}),(0,n.jsx)(e.span,{className:"vlist-s",children:"\u200b"})]}),(0,n.jsx)(e.span,{className:"vlist-r",children:(0,n.jsx)(e.span,{className:"vlist",style:{height:"0.15em"},children:(0,n.jsx)(e.span,{})})})]})})]}),(0,n.jsx)(e.span,{className:"mspace",style:{marginRight:"0.2222em"}}),(0,n.jsx)(e.span,{className:"mbin",children:"\u2212"}),(0,n.jsx)(e.span,{className:"mspace",style:{marginRight:"0.2222em"}})]}),(0,n.jsxs)(e.span,{className:"base",children:[(0,n.jsx)(e.span,{className:"strut",style:{height:"1em",verticalAlign:"-0.25em"}}),(0,n.jsxs)(e.span,{className:"mord",children:[(0,n.jsx)(e.span,{className:"mord mathnormal",children:"Q"}),(0,n.jsx)(e.span,{className:"msupsub",children:(0,n.jsxs)(e.span,{className:"vlist-t vlist-t2",children:[(0,n.jsxs)(e.span,{className:"vlist-r",children:[(0,n.jsx)(e.span,{className:"vlist",style:{height:"0.3117em"},children:(0,n.jsxs)(e.span,{style:{top:"-2.55em",marginLeft:"0em",marginRight:"0.05em"},children:[(0,n.jsx)(e.span,{className:"pstrut",style:{height:"2.7em"}}),(0,n.jsx)(e.span,{className:"sizing reset-size6 size3 mtight",children:(0,n.jsx)(e.span,{className:"mord mathnormal mtight",children:"i"})})]})}),(0,n.jsx)(e.span,{className:"vlist-s",children:"\u200b"})]}),(0,n.jsx)(e.span,{className:"vlist-r",children:(0,n.jsx)(e.span,{className:"vlist",style:{height:"0.15em"},children:(0,n.jsx)(e.span,{})})})]})})]}),(0,n.jsx)(e.span,{className:"mpunct",children:","}),(0,n.jsx)(e.span,{className:"mspace",style:{marginRight:"0.1667em"}}),(0,n.jsx)(e.span,{className:"mord",children:"0"}),(0,n.jsx)(e.span,{className:"mclose",children:")"})]})]})]}),"\nto do: replace formula with example DataFrame visualization"]}),"\n"]}),"\n",(0,n.jsxs)(e.li,{children:["\n",(0,n.jsxs)(e.p,{children:[(0,n.jsx)(e.strong,{children:"Sum of negative differences:"})," Add only the absolute values where the selected distribution (e.g. P_i) is less than the other (e.g. Q_i). This essentially sums the deficient probabilities in one distribution relative to the other. ",(0,n.jsx)(e.br,{}),"\n",(0,n.jsxs)(e.span,{className:"katex",children:[(0,n.jsx)(e.span,{className:"katex-mathml",children:(0,n.jsx)(e.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,n.jsxs)(e.semantics,{children:[(0,n.jsxs)(e.mrow,{children:[(0,n.jsx)(e.mtext,{children:"TVD"}),(0,n.jsx)(e.mo,{children:"="}),(0,n.jsx)(e.mo,{children:"\u2211"}),(0,n.jsx)(e.mi,{children:"a"}),(0,n.jsx)(e.mi,{children:"b"}),(0,n.jsx)(e.mi,{children:"s"}),(0,n.jsx)(e.mo,{stretchy:"false",children:"("}),(0,n.jsx)(e.mi,{children:"m"}),(0,n.jsx)(e.mi,{children:"i"}),(0,n.jsx)(e.mi,{children:"n"}),(0,n.jsx)(e.mo,{stretchy:"false",children:"("}),(0,n.jsxs)(e.msub,{children:[(0,n.jsx)(e.mi,{children:"P"}),(0,n.jsx)(e.mi,{children:"i"})]}),(0,n.jsx)(e.mo,{children:"\u2212"}),(0,n.jsxs)(e.msub,{children:[(0,n.jsx)(e.mi,{children:"Q"}),(0,n.jsx)(e.mi,{children:"i"})]}),(0,n.jsx)(e.mo,{separator:"true",children:","}),(0,n.jsx)(e.mn,{children:"0"}),(0,n.jsx)(e.mo,{stretchy:"false",children:")"}),(0,n.jsx)(e.mo,{stretchy:"false",children:")"})]}),(0,n.jsx)(e.annotation,{encoding:"application/x-tex",children:"\\text{TVD}=\\sum abs(min(P_i-Q_i,0))"})]})})}),(0,n.jsxs)(e.span,{className:"katex-html","aria-hidden":"true",children:[(0,n.jsxs)(e.span,{className:"base",children:[(0,n.jsx)(e.span,{className:"strut",style:{height:"0.6833em"}}),(0,n.jsx)(e.span,{className:"mord text",children:(0,n.jsx)(e.span,{className:"mord",children:"TVD"})}),(0,n.jsx)(e.span,{className:"mspace",style:{marginRight:"0.2778em"}}),(0,n.jsx)(e.span,{className:"mrel",children:"="}),(0,n.jsx)(e.span,{className:"mspace",style:{marginRight:"0.2778em"}})]}),(0,n.jsxs)(e.span,{className:"base",children:[(0,n.jsx)(e.span,{className:"strut",style:{height:"1em",verticalAlign:"-0.25em"}}),(0,n.jsx)(e.span,{className:"mop op-symbol small-op",style:{position:"relative",top:"0em"},children:"\u2211"}),(0,n.jsx)(e.span,{className:"mspace",style:{marginRight:"0.1667em"}}),(0,n.jsx)(e.span,{className:"mord mathnormal",children:"ab"}),(0,n.jsx)(e.span,{className:"mord mathnormal",children:"s"}),(0,n.jsx)(e.span,{className:"mopen",children:"("}),(0,n.jsx)(e.span,{className:"mord mathnormal",children:"min"}),(0,n.jsx)(e.span,{className:"mopen",children:"("}),(0,n.jsxs)(e.span,{className:"mord",children:[(0,n.jsx)(e.span,{className:"mord mathnormal",style:{marginRight:"0.13889em"},children:"P"}),(0,n.jsx)(e.span,{className:"msupsub",children:(0,n.jsxs)(e.span,{className:"vlist-t vlist-t2",children:[(0,n.jsxs)(e.span,{className:"vlist-r",children:[(0,n.jsx)(e.span,{className:"vlist",style:{height:"0.3117em"},children:(0,n.jsxs)(e.span,{style:{top:"-2.55em",marginLeft:"-0.1389em",marginRight:"0.05em"},children:[(0,n.jsx)(e.span,{className:"pstrut",style:{height:"2.7em"}}),(0,n.jsx)(e.span,{className:"sizing reset-size6 size3 mtight",children:(0,n.jsx)(e.span,{className:"mord mathnormal mtight",children:"i"})})]})}),(0,n.jsx)(e.span,{className:"vlist-s",children:"\u200b"})]}),(0,n.jsx)(e.span,{className:"vlist-r",children:(0,n.jsx)(e.span,{className:"vlist",style:{height:"0.15em"},children:(0,n.jsx)(e.span,{})})})]})})]}),(0,n.jsx)(e.span,{className:"mspace",style:{marginRight:"0.2222em"}}),(0,n.jsx)(e.span,{className:"mbin",children:"\u2212"}),(0,n.jsx)(e.span,{className:"mspace",style:{marginRight:"0.2222em"}})]}),(0,n.jsxs)(e.span,{className:"base",children:[(0,n.jsx)(e.span,{className:"strut",style:{height:"1em",verticalAlign:"-0.25em"}}),(0,n.jsxs)(e.span,{className:"mord",children:[(0,n.jsx)(e.span,{className:"mord mathnormal",children:"Q"}),(0,n.jsx)(e.span,{className:"msupsub",children:(0,n.jsxs)(e.span,{className:"vlist-t vlist-t2",children:[(0,n.jsxs)(e.span,{className:"vlist-r",children:[(0,n.jsx)(e.span,{className:"vlist",style:{height:"0.3117em"},children:(0,n.jsxs)(e.span,{style:{top:"-2.55em",marginLeft:"0em",marginRight:"0.05em"},children:[(0,n.jsx)(e.span,{className:"pstrut",style:{height:"2.7em"}}),(0,n.jsx)(e.span,{className:"sizing reset-size6 size3 mtight",children:(0,n.jsx)(e.span,{className:"mord mathnormal mtight",children:"i"})})]})}),(0,n.jsx)(e.span,{className:"vlist-s",children:"\u200b"})]}),(0,n.jsx)(e.span,{className:"vlist-r",children:(0,n.jsx)(e.span,{className:"vlist",style:{height:"0.15em"},children:(0,n.jsx)(e.span,{})})})]})})]}),(0,n.jsx)(e.span,{className:"mpunct",children:","}),(0,n.jsx)(e.span,{className:"mspace",style:{marginRight:"0.1667em"}}),(0,n.jsx)(e.span,{className:"mord",children:"0"}),(0,n.jsx)(e.span,{className:"mclose",children:"))"})]})]})]}),"\nto do: replace formula with example DataFrame visualization"]}),"\n"]}),"\n"]})]})]})}function d(s={}){const{wrapper:e}={...(0,i.R)(),...s.components};return e?(0,n.jsx)(e,{...s,children:(0,n.jsx)(h,{...s})}):h(s)}},8597:(s,e,a)=>{a.d(e,{A:()=>i});a(6540);var n=a(4848);const i=s=>{let{data:e}=s,a=[],i=[],t="",l=[];if(e){const s=JSON.parse(e);a=s.columns||[],i=s.data||[],t=s.indexName||"Index",l=s.index||[]}return(0,n.jsx)("div",{className:"dataframe-container",children:(0,n.jsxs)("table",{className:"dataframe-table",children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{children:t}),a.map(((s,e)=>(0,n.jsx)("th",{children:s},e)))]})}),(0,n.jsx)("tbody",{children:i.map(((s,e)=>(0,n.jsxs)("tr",{children:[(0,n.jsx)("td",{className:"index-value",children:l[e]}),s.map(((s,e)=>{return(0,n.jsx)("td",{children:(a=s,"boolean"==typeof a?a.toString().charAt(0).toUpperCase()+a.toString().slice(1):a)},e);var a}))]},e)))})]})})}},5158:(s,e,a)=>{a.d(e,{A:()=>t});var n=a(6540),i=a(4848);const t=function(s){let{src:e,sourceLink:a,aspectRatio:t=16/9}=s;const[l,r]=(0,n.useState)(0),[c,m]=(0,n.useState)(0),h=(0,n.useRef)(null);return(0,n.useEffect)((()=>{const s=()=>{if(h.current){const s=h.current.offsetWidth;m(s/t)}};return s(),window.addEventListener("resize",s),()=>window.removeEventListener("resize",s)}),[t]),(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("div",{ref:h,style:{width:"100%",position:"relative",maxWidth:"100%",backgroundColor:"white"},children:(0,i.jsx)("iframe",{src:e,style:{width:"100%",height:`${c}px`,border:"0",allowFullScreen:!0}},l)}),(0,i.jsx)("div",{style:{display:"flex",justifyContent:"center",margin:"20px 0"},children:(0,i.jsx)("a",{href:a,target:"_blank",rel:"noopener noreferrer",children:"(Source)"})}),(0,i.jsx)("div",{style:{display:"flex",justifyContent:"center",margin:"10px 0"},children:(0,i.jsx)("button",{onClick:()=>{r((s=>s+1))},style:{backgroundColor:"#4CAF50",color:"white",padding:"10px 20px",border:"none",borderRadius:"5px",cursor:"pointer",outline:"none",fontSize:"16px",fontWeight:"bold",boxShadow:"0 4px 8px rgba(0,0,0,0.1)",transition:"background-color 0.3s"},onMouseOver:s=>s.currentTarget.style.backgroundColor="#45a049",onMouseOut:s=>s.currentTarget.style.backgroundColor="#4CAF50",children:"Restart Diagram"})})]})}},8453:(s,e,a)=>{a.d(e,{R:()=>l,x:()=>r});var n=a(6540);const i={},t=n.createContext(i);function l(s){const e=n.useContext(t);return n.useMemo((function(){return"function"==typeof s?s(e):{...e,...s}}),[e,s])}function r(s){let e;return e=s.disableParentContext?"function"==typeof s.components?s.components(i):s.components||i:l(s.components),n.createElement(t.Provider,{value:e},s.children)}}}]); \ No newline at end of file diff --git a/assets/js/9f1843d8.98b107ad.js b/assets/js/9f1843d8.98b107ad.js new file mode 100644 index 00000000..c49584ff --- /dev/null +++ b/assets/js/9f1843d8.98b107ad.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunkbpd_reference=self.webpackChunkbpd_reference||[]).push([[9894],{6171:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>d,contentTitle:()=>l,default:()=>p,frontMatter:()=>o,metadata:()=>c,toc:()=>h});var s=n(4848),i=n(8453),a=n(8597),r=n(5158);const o={sidebar_position:7,sidebar_label:"Permutation Test",title:"Permutation Test",tags:["querying","functions","for-loop","histogram"]},l=void 0,c={id:"statistical-inference/permutation_test",title:"Permutation Test",description:"Concept",source:"@site/docs/statistical-inference/permutation_test.md",sourceDirName:"statistical-inference",slug:"/statistical-inference/permutation_test",permalink:"/bpd-reference/docs/statistical-inference/permutation_test",draft:!1,unlisted:!1,editUrl:"https://github.com/dsc-courses/bpd-reference/tree/main/docs/statistical-inference/permutation_test.md",tags:[{label:"querying",permalink:"/bpd-reference/docs/tags/querying"},{label:"functions",permalink:"/bpd-reference/docs/tags/functions"},{label:"for-loop",permalink:"/bpd-reference/docs/tags/for-loop"},{label:"histogram",permalink:"/bpd-reference/docs/tags/histogram"}],version:"current",sidebarPosition:7,frontMatter:{sidebar_position:7,sidebar_label:"Permutation Test",title:"Permutation Test",tags:["querying","functions","for-loop","histogram"]},sidebar:"statsSidebar",previous:{title:"Hypothesis Test",permalink:"/bpd-reference/docs/statistical-inference/hypothesis_test"},next:{title:"The Standard Normal Distribution",permalink:"/bpd-reference/docs/statistical-inference/standard_normal_distribution"}},d={},h=[{value:"Concept",id:"concept",level:2},{value:"Code Example (Absolute Difference)",id:"code-example-absolute-difference",level:2},{value:"1. State the question/hypothesis",id:"1-state-the-questionhypothesis",level:3},{value:"2. Query the DataFrame",id:"2-query-the-dataframe",level:3},{value:"3. Create a function to calculate test statistic",id:"3-create-a-function-to-calculate-test-statistic",level:3},{value:"4. Simulate the permutation test",id:"4-simulate-the-permutation-test",level:3},{value:"5. Conclusion",id:"5-conclusion",level:3},{value:"6. Extra",id:"6-extra",level:3}];function u(e){const t={a:"a",admonition:"admonition",annotation:"annotation",code:"code",em:"em",h2:"h2",h3:"h3",hr:"hr",img:"img",li:"li",math:"math",mo:"mo",mrow:"mrow",ol:"ol",p:"p",pre:"pre",semantics:"semantics",span:"span",strong:"strong",ul:"ul",...(0,i.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(t.h2,{id:"concept",children:"Concept"}),"\n",(0,s.jsx)(t.admonition,{title:"Key Idea",type:"tip",children:(0,s.jsx)(t.p,{children:"We use a permutation test to test whether two samples are drawn from the same population."})}),"\n",(0,s.jsxs)(t.admonition,{title:"Terminology",type:"info",children:[(0,s.jsxs)(t.p,{children:[(0,s.jsx)(t.strong,{children:"Permutation"}),": A permutation of a sequence is a rearrangement of the elements in that sequence."]}),(0,s.jsxs)(t.ul,{children:["\n",(0,s.jsx)(t.li,{children:"Example: 'BAC' and 'CAB' are both permutations of the string 'ABC'."}),"\n",(0,s.jsx)(t.li,{children:"We create permutations by shuffling."}),"\n"]}),(0,s.jsxs)(t.p,{children:[(0,s.jsx)(t.strong,{children:"Permutation tests:"})," A permutation test is a type of A/B test (and a type of hypothesis test). It tests whether two samples come from the same population distribution. To conduct a permutation test:"]}),(0,s.jsxs)(t.ol,{children:["\n",(0,s.jsx)(t.li,{children:"Shuffle the group labels (i.e. the Trues and Falses) to generate two new samples under the null."}),"\n",(0,s.jsx)(t.li,{children:"Compute the test statistic (i.e. the difference in group means)."}),"\n",(0,s.jsx)(t.li,{children:"Repeat steps 1 and 2 to generate an empirical distribution of the test statistics (i.e. the difference in group means)."}),"\n",(0,s.jsx)(t.li,{children:"See where the observed statistic lies in the empirical distribution. If, in our simulations, we rarely saw a difference in group means as extreme as the observed difference in group means, we have evidence to reject the null."}),"\n"]})]}),"\n",(0,s.jsx)(t.admonition,{type:"note",children:(0,s.jsx)(t.p,{children:"While shuffling, the size of the two new samples should be the same as the observed samples."})}),"\n",(0,s.jsxs)(t.p,{children:["The diagram below provides an overview of conducting a permutation test, although it references a different dataset. ",(0,s.jsx)(t.a,{href:"https://www.jwilber.me/permutationtest/",children:"Here"})," is another useful visualization. For additional helpful visual guides, please visit the ",(0,s.jsx)(t.a,{href:"https://dsc10.com/diagrams/",children:"Diagrams"})," site."]}),"\n",(0,s.jsx)(r.A,{src:"https://docs.google.com/presentation/d/e/2PACX-1vSovXDonR6EmjrT45h4pY1mwmcKFMWVSdgpbKHC5HNTm9sbG7dojvvCDEQCjuk2dk1oA4gmwMogr8ZL/embed?start=true&loop=false&delayms=3000&rm=minimal",sourceLink:"https://docs.google.com/presentation/d/1TTWoQ7FU4tzBGc7EskF6WYccIn1BWQbTSizAiFc2p2o/edit?usp=sharing"}),"\n",(0,s.jsx)(t.hr,{}),"\n",(0,s.jsx)(t.h2,{id:"code-example-absolute-difference",children:"Code Example (Absolute Difference)"}),"\n",(0,s.jsx)(t.h3,{id:"1-state-the-questionhypothesis",children:"1. State the question/hypothesis"}),"\n",(0,s.jsxs)(t.admonition,{title:"Hypotheses",type:"info",children:[(0,s.jsx)(t.p,{children:"We will test the following pair of hypotheses at the standard p = 0.05 significance level:"}),(0,s.jsxs)(t.ul,{children:["\n",(0,s.jsxs)(t.li,{children:[(0,s.jsx)(t.strong,{children:"Null Hypothesis:"})," In the population, weights of dogs and cats have the ",(0,s.jsx)(t.strong,{children:"same"})," distribution, and the observed differences in our samples are due to random chance."]}),"\n",(0,s.jsxs)(t.li,{children:[(0,s.jsx)(t.strong,{children:"Alternative Hypothesis:"})," In the population, dogs and cats have ",(0,s.jsx)(t.strong,{children:"different"})," weights, on average. The observed differences in our samples cannot be explained by random chance alone."]}),"\n"]})]}),"\n",(0,s.jsxs)(t.p,{children:['Since the alternative hypothesis is of the form "A and B are different," the ',(0,s.jsx)(t.strong,{children:"test statistic"})," should measure distance and use an absolute value."]}),"\n",(0,s.jsxs)(t.p,{children:[(0,s.jsxs)(t.span,{className:"katex",children:[(0,s.jsx)(t.span,{className:"katex-mathml",children:(0,s.jsx)(t.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,s.jsxs)(t.semantics,{children:[(0,s.jsx)(t.mrow,{children:(0,s.jsx)(t.mo,{children:"\u2234"})}),(0,s.jsx)(t.annotation,{encoding:"application/x-tex",children:"\\therefore"})]})})}),(0,s.jsx)(t.span,{className:"katex-html","aria-hidden":"true",children:(0,s.jsxs)(t.span,{className:"base",children:[(0,s.jsx)(t.span,{className:"strut",style:{height:"0.6922em"}}),(0,s.jsx)(t.span,{className:"mrel amsrm",children:"\u2234"})]})})]})," We use ",(0,s.jsx)(t.strong,{children:"absolute difference in group means"})," as the test statistic."]}),"\n",(0,s.jsx)(t.hr,{}),"\n",(0,s.jsx)(t.h3,{id:"2-query-the-dataframe",children:"2. Query the DataFrame"}),"\n",(0,s.jsx)(t.p,{children:"Since we want to compare the distributions of only cats and dogs, we need to make sure to only include the relevant pieces of data (e.g., cats and dogs weights)."}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-python",children:"# Create a boolean Series that references which rows fulfill either condition.\nquerying_condition = (full_pets.get('Species') == 'dog') | (full_pets.get('Species') == 'cat')\n# Query.\ncats_dogs = full_pets[querying_condition]\n# Display the first 5 rows only.\ncats_dogs.take(np.arange(5)) \n"})}),"\n",(0,s.jsx)(a.A,{data:'{"columns":["ID","Species","Color","Weight","Age","Is_Cat","Owner_Comment"],"index":[0,1,2,3,4],"data":[["dog_001","dog","black",40.0,5.0,false," There are no bad dogs, only bad owners."],["cat_001","cat","golden",1.5,0.2,true,"My best birthday present ever!!!"],["cat_002","cat","black",15.0,9.0,true,"****All you need is love and a cat.****"],["dog_002","dog","white",80.0,2.0,false,"Love is a wet nose and a wagging tail."],["dog_003","dog","black",25.0,0.5,false,"Be the person your dog thinks you are."]]}'}),"\n",(0,s.jsx)(t.hr,{}),"\n",(0,s.jsx)(t.h3,{id:"3-create-a-function-to-calculate-test-statistic",children:"3. Create a function to calculate test statistic"}),"\n",(0,s.jsx)(t.p,{children:"Since our hypotheses depend on the test statistic, create a function to be able to calculate it during every trial of our permutation test."}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-python",children:"def difference_in_means(cats_dogs):\n \"\"\"\n Calculate the absolute difference in the mean weight of dogs and cats.\n ---\n Input:\n cats_dogs: a DataFrame containing the columns 'Species' and 'Weight'.\n ---\n Output:\n The absolute difference in the mean weight of dogs and cats.\n \"\"\"\n means = cats_dogs.groupby('Species').mean()\n return np.abs((means.get('Weight').loc['dog'] - means.get('Weight').loc['cat']))\n"})}),"\n",(0,s.jsx)(t.p,{children:(0,s.jsx)(t.em,{children:"Note: Although we can simply do this in the for-loop shown in the next step, we can practice good coding habits by separating our code into readable bits!"})}),"\n",(0,s.jsx)(t.hr,{}),"\n",(0,s.jsx)(t.h3,{id:"4-simulate-the-permutation-test",children:"4. Simulate the permutation test"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-python",children:"n = 500 # Number of simulations.\nstatistics = np.array([]) # Array to keep track of the difference in means for each iteration.\nfor i in np.arange(n): # Run the simulation `n` number of times\n # 1. Shuffle the species.\n shuffled = cats_dogs.assign(Species=np.random.permutation(cats_dogs.get('Species')))\n\n # 2. Compute the test statistic.\n statistic = difference_in_means(shuffled)\n\n # 3. Save the result.\n statistics = np.append(statistics, statistic)\n"})}),"\n",(0,s.jsxs)(t.p,{children:["This code will run the permutation test 500 times, but a different reasonable number can be used instead. It is ",(0,s.jsx)(t.strong,{children:"crucial"})," to keep track of the difference in means each time our for-loop runs so that the number of simulated values can be displayed."]}),"\n",(0,s.jsx)(t.hr,{}),"\n",(0,s.jsx)(t.h3,{id:"5-conclusion",children:"5. Conclusion"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-python",children:'observed = difference_in_means(cats_dogs)\np_value = np.count_nonzero(statistics >= observed) / n\n\nprint("The observed value of the test statistic is:", observed)\nprint("The p-value is:", p_value)\n'})}),"\n",(0,s.jsxs)(t.p,{children:[(0,s.jsx)(t.strong,{children:"The observed value of the test statistic is: 30.361111111111107"})," ",(0,s.jsx)("br",{}),"\n",(0,s.jsx)(t.strong,{children:"The p-value is: 0.004"})]}),"\n",(0,s.jsx)(t.p,{children:"Using a significance level of 0.05:"}),"\n",(0,s.jsx)(t.admonition,{title:"Conclusion",type:"info",children:(0,s.jsxs)(t.ul,{children:["\n",(0,s.jsx)(t.li,{children:"Under the null hypothesis, we rarely see a difference greater than the observed value."}),"\n",(0,s.jsxs)(t.li,{children:["Therefore, we ",(0,s.jsx)(t.strong,{children:"reject"})," the null hypothesis: the evidence implies that the two groups do not come from the same distribution."]}),"\n",(0,s.jsx)(t.li,{children:"Still, we cannot conclude that species causes a different weight because there may be other confounding variables."}),"\n"]})}),"\n",(0,s.jsx)(t.hr,{}),"\n",(0,s.jsx)(t.h3,{id:"6-extra",children:"6. Extra"}),"\n",(0,s.jsx)(t.p,{children:"Let's see how our observed statistic compares to the overall simulated values!"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-python",children:"# Create the histogram.\nbpd.DataFrame().assign(statistics=statistics).plot(kind='hist', bins=20, density=True, ec='w')\n# Don't worry about this line - you won't need to know it for this course!\nplt.axvline(x=observed, c='black', linewidth=4, label='population difference in means')\n"})}),"\n",(0,s.jsx)(t.p,{children:(0,s.jsx)(t.img,{alt:"Distribution",src:n(8803).A+"",width:"576",height:"413"})}),"\n",(0,s.jsxs)(t.p,{children:["From this graph, we can tell that there is barely any data to the ",(0,s.jsx)(t.strong,{children:"right"})," of the black vertical line (our observed statistic), meaning we have a very low p-value!"]})]})}function p(e={}){const{wrapper:t}={...(0,i.R)(),...e.components};return t?(0,s.jsx)(t,{...e,children:(0,s.jsx)(u,{...e})}):u(e)}},8597:(e,t,n)=>{n.d(t,{A:()=>i});n(6540);var s=n(4848);const i=e=>{let{data:t}=e,n=[],i=[],a="",r=[];if(t){const e=JSON.parse(t);n=e.columns||[],i=e.data||[],a=e.indexName||"Index",r=e.index||[]}return(0,s.jsx)("div",{className:"dataframe-container",children:(0,s.jsxs)("table",{className:"dataframe-table",children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{children:a}),n.map(((e,t)=>(0,s.jsx)("th",{children:e},t)))]})}),(0,s.jsx)("tbody",{children:i.map(((e,t)=>(0,s.jsxs)("tr",{children:[(0,s.jsx)("td",{className:"index-value",children:r[t]}),e.map(((e,t)=>{return(0,s.jsx)("td",{children:(n=e,"boolean"==typeof n?n.toString().charAt(0).toUpperCase()+n.toString().slice(1):n)},t);var n}))]},t)))})]})})}},5158:(e,t,n)=>{n.d(t,{A:()=>a});var s=n(6540),i=n(4848);const a=function(e){let{src:t,sourceLink:n,aspectRatio:a=16/9}=e;const[r,o]=(0,s.useState)(0),[l,c]=(0,s.useState)(0),d=(0,s.useRef)(null);return(0,s.useEffect)((()=>{const e=()=>{if(d.current){const e=d.current.offsetWidth;c(e/a)}};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)}),[a]),(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("div",{ref:d,style:{width:"100%",position:"relative",maxWidth:"100%",backgroundColor:"white"},children:(0,i.jsx)("iframe",{src:t,style:{width:"100%",height:`${l}px`,border:"0",allowFullScreen:!0}},r)}),(0,i.jsx)("div",{style:{display:"flex",justifyContent:"center",margin:"20px 0"},children:(0,i.jsx)("a",{href:n,target:"_blank",rel:"noopener noreferrer",children:"(Source)"})}),(0,i.jsx)("div",{style:{display:"flex",justifyContent:"center",margin:"10px 0"},children:(0,i.jsx)("button",{onClick:()=>{o((e=>e+1))},style:{backgroundColor:"#4CAF50",color:"white",padding:"10px 20px",border:"none",borderRadius:"5px",cursor:"pointer",outline:"none",fontSize:"16px",fontWeight:"bold",boxShadow:"0 4px 8px rgba(0,0,0,0.1)",transition:"background-color 0.3s"},onMouseOver:e=>e.currentTarget.style.backgroundColor="#45a049",onMouseOut:e=>e.currentTarget.style.backgroundColor="#4CAF50",children:"Restart Diagram"})})]})}},8803:(e,t,n)=>{n.d(t,{A:()=>s});const s=n.p+"assets/images/permutation-test-fae4df12733e667b05989b96bf08d9a9.png"},8453:(e,t,n)=>{n.d(t,{R:()=>r,x:()=>o});var s=n(6540);const i={},a=s.createContext(i);function r(e){const t=s.useContext(a);return s.useMemo((function(){return"function"==typeof e?e(t):{...t,...e}}),[t,e])}function o(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:r(e.components),s.createElement(a.Provider,{value:t},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/9f1843d8.e87af32a.js b/assets/js/9f1843d8.e87af32a.js deleted file mode 100644 index 7491c9dd..00000000 --- a/assets/js/9f1843d8.e87af32a.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunkbpd_reference=self.webpackChunkbpd_reference||[]).push([[9894],{6171:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>d,contentTitle:()=>l,default:()=>p,frontMatter:()=>o,metadata:()=>c,toc:()=>h});var s=n(4848),i=n(8453),a=n(8597),r=n(5158);const o={sidebar_position:7,sidebar_label:"Permutation Test",title:"Permutation Test",tags:["querying","functions","for-loop","histogram"]},l=void 0,c={id:"statistical-inference/permutation_test",title:"Permutation Test",description:"Concept",source:"@site/docs/statistical-inference/permutation_test.md",sourceDirName:"statistical-inference",slug:"/statistical-inference/permutation_test",permalink:"/bpd-reference/docs/statistical-inference/permutation_test",draft:!1,unlisted:!1,editUrl:"https://github.com/dsc-courses/bpd-reference/tree/main/docs/statistical-inference/permutation_test.md",tags:[{label:"querying",permalink:"/bpd-reference/docs/tags/querying"},{label:"functions",permalink:"/bpd-reference/docs/tags/functions"},{label:"for-loop",permalink:"/bpd-reference/docs/tags/for-loop"},{label:"histogram",permalink:"/bpd-reference/docs/tags/histogram"}],version:"current",sidebarPosition:7,frontMatter:{sidebar_position:7,sidebar_label:"Permutation Test",title:"Permutation Test",tags:["querying","functions","for-loop","histogram"]},sidebar:"statsSidebar",previous:{title:"Hypothesis Test",permalink:"/bpd-reference/docs/statistical-inference/hypothesis_test"},next:{title:"The Standard Normal Distribution",permalink:"/bpd-reference/docs/statistical-inference/standard_normal_distribution"}},d={},h=[{value:"Concept",id:"concept",level:2},{value:"Code Example",id:"code-example",level:2},{value:"1. State the question/hypothesis",id:"1-state-the-questionhypothesis",level:3},{value:"2. Query the DataFrame",id:"2-query-the-dataframe",level:3},{value:"3. Create a function to calculate test statistic",id:"3-create-a-function-to-calculate-test-statistic",level:3},{value:"4. Simulate the permutation test",id:"4-simulate-the-permutation-test",level:3},{value:"5. Conclusion",id:"5-conclusion",level:3},{value:"6. Extra",id:"6-extra",level:3}];function u(e){const t={a:"a",admonition:"admonition",annotation:"annotation",code:"code",em:"em",h2:"h2",h3:"h3",hr:"hr",img:"img",li:"li",math:"math",mo:"mo",mrow:"mrow",ol:"ol",p:"p",pre:"pre",semantics:"semantics",span:"span",strong:"strong",ul:"ul",...(0,i.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(t.h2,{id:"concept",children:"Concept"}),"\n",(0,s.jsx)(t.admonition,{title:"Key Idea",type:"tip",children:(0,s.jsx)(t.p,{children:"We use a permutation test to test whether two samples are drawn from the same population."})}),"\n",(0,s.jsxs)(t.admonition,{title:"Terminology",type:"info",children:[(0,s.jsxs)(t.p,{children:[(0,s.jsx)(t.strong,{children:"Permutation"}),": A permutation of a sequence is a rearrangement of the elements in that sequence."]}),(0,s.jsxs)(t.ul,{children:["\n",(0,s.jsx)(t.li,{children:"Example: 'BAC' and 'CAB' are both permutations of the string 'ABC'."}),"\n",(0,s.jsx)(t.li,{children:"We create permutations by shuffling."}),"\n"]}),(0,s.jsxs)(t.p,{children:[(0,s.jsx)(t.strong,{children:"Permutation tests:"})," A permutation test is a type of A/B test (and a type of hypothesis test). It tests whether two samples come from the same population distribution. To conduct a permutation test:"]}),(0,s.jsxs)(t.ol,{children:["\n",(0,s.jsx)(t.li,{children:"Shuffle the group labels (i.e. the Trues and Falses) to generate two new samples under the null."}),"\n",(0,s.jsx)(t.li,{children:"Compute the test statistic (i.e. the difference in group means)."}),"\n",(0,s.jsx)(t.li,{children:"Repeat steps 1 and 2 to generate an empirical distribution of the test statistics (i.e. the difference in group means)."}),"\n",(0,s.jsx)(t.li,{children:"See where the observed statistic lies in the empirical distribution. If, in our simulations, we rarely saw a difference in group means as extreme as the observed difference in group means, we have evidence to reject the null."}),"\n"]})]}),"\n",(0,s.jsx)(t.admonition,{type:"note",children:(0,s.jsx)(t.p,{children:"While shuffling, the size of the two new samples should be the same as the observed samples."})}),"\n",(0,s.jsxs)(t.p,{children:["The diagram below provides an overview of conducting a permutation test, although it references a different dataset. ",(0,s.jsx)(t.a,{href:"https://www.jwilber.me/permutationtest/",children:"Here"})," is another useful visualization. For additional helpful visual guides, please visit the ",(0,s.jsx)(t.a,{href:"https://dsc10.com/diagrams/",children:"Diagrams"})," site."]}),"\n",(0,s.jsx)(r.A,{src:"https://docs.google.com/presentation/d/e/2PACX-1vSovXDonR6EmjrT45h4pY1mwmcKFMWVSdgpbKHC5HNTm9sbG7dojvvCDEQCjuk2dk1oA4gmwMogr8ZL/embed?start=true&loop=false&delayms=3000&rm=minimal",sourceLink:"https://docs.google.com/presentation/d/1TTWoQ7FU4tzBGc7EskF6WYccIn1BWQbTSizAiFc2p2o/edit?usp=sharing"}),"\n",(0,s.jsx)(t.hr,{}),"\n",(0,s.jsx)(t.h2,{id:"code-example",children:"Code Example"}),"\n",(0,s.jsx)(t.h3,{id:"1-state-the-questionhypothesis",children:"1. State the question/hypothesis"}),"\n",(0,s.jsxs)(t.admonition,{title:"Hypotheses",type:"info",children:[(0,s.jsx)(t.p,{children:"We will test the following pair of hypotheses at the standard p = 0.05 significance level:"}),(0,s.jsxs)(t.ul,{children:["\n",(0,s.jsxs)(t.li,{children:[(0,s.jsx)(t.strong,{children:"Null Hypothesis:"})," In the population, weights of dogs and cats have the ",(0,s.jsx)(t.strong,{children:"same"})," distribution, and the observed differences in our samples are due to random chance."]}),"\n",(0,s.jsxs)(t.li,{children:[(0,s.jsx)(t.strong,{children:"Alternative Hypothesis:"})," In the population, dogs and cats have ",(0,s.jsx)(t.strong,{children:"different"})," weights, on average. The observed differences in our samples cannot be explained by random chance alone."]}),"\n"]})]}),"\n",(0,s.jsxs)(t.p,{children:['Since the alternative hypothesis is of the form "A and B are different," the ',(0,s.jsx)(t.strong,{children:"test statistic"})," should measure distance and use an absolute value."]}),"\n",(0,s.jsxs)(t.p,{children:[(0,s.jsxs)(t.span,{className:"katex",children:[(0,s.jsx)(t.span,{className:"katex-mathml",children:(0,s.jsx)(t.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,s.jsxs)(t.semantics,{children:[(0,s.jsx)(t.mrow,{children:(0,s.jsx)(t.mo,{children:"\u2234"})}),(0,s.jsx)(t.annotation,{encoding:"application/x-tex",children:"\\therefore"})]})})}),(0,s.jsx)(t.span,{className:"katex-html","aria-hidden":"true",children:(0,s.jsxs)(t.span,{className:"base",children:[(0,s.jsx)(t.span,{className:"strut",style:{height:"0.6922em"}}),(0,s.jsx)(t.span,{className:"mrel amsrm",children:"\u2234"})]})})]})," We use ",(0,s.jsx)(t.strong,{children:"absolute difference in group means"})," as the test statistic."]}),"\n",(0,s.jsx)(t.hr,{}),"\n",(0,s.jsx)(t.h3,{id:"2-query-the-dataframe",children:"2. Query the DataFrame"}),"\n",(0,s.jsx)(t.p,{children:"Since we want to compare the distributions of only cats and dogs, we need to make sure to only include the relevant pieces of data (e.g., cats and dogs weights)."}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-python",children:"# Create a boolean Series that references which rows fulfill either condition.\nquerying_condition = (full_pets.get('Species') == 'dog') | (full_pets.get('Species') == 'cat')\n# Query.\ncats_dogs = full_pets[querying_condition]\n# Display the first 5 rows only.\ncats_dogs.take(np.arange(5)) \n"})}),"\n",(0,s.jsx)(a.A,{data:'{"columns":["ID","Species","Color","Weight","Age","Is_Cat","Owner_Comment"],"index":[0,1,2,3,4],"data":[["dog_001","dog","black",40.0,5.0,false," There are no bad dogs, only bad owners."],["cat_001","cat","golden",1.5,0.2,true,"My best birthday present ever!!!"],["cat_002","cat","black",15.0,9.0,true,"****All you need is love and a cat.****"],["dog_002","dog","white",80.0,2.0,false,"Love is a wet nose and a wagging tail."],["dog_003","dog","black",25.0,0.5,false,"Be the person your dog thinks you are."]]}'}),"\n",(0,s.jsx)(t.hr,{}),"\n",(0,s.jsx)(t.h3,{id:"3-create-a-function-to-calculate-test-statistic",children:"3. Create a function to calculate test statistic"}),"\n",(0,s.jsx)(t.p,{children:"Since our hypotheses depend on the test statistic, create a function to be able to calculate it during every trial of our permutation test."}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-python",children:"def difference_in_means(cats_dogs):\n \"\"\"\n Calculate the absolute difference in the mean weight of dogs and cats.\n ---\n Input:\n cats_dogs: a DataFrame containing the columns 'Species' and 'Weight'.\n ---\n Output:\n The absolute difference in the mean weight of dogs and cats.\n \"\"\"\n means = cats_dogs.groupby('Species').mean()\n return np.abs((means.get('Weight').loc['dog'] - means.get('Weight').loc['cat']))\n"})}),"\n",(0,s.jsx)(t.p,{children:(0,s.jsx)(t.em,{children:"Note: Although we can simply do this in the for-loop shown in the next step, we can practice good coding habits by separating our code into readable bits!"})}),"\n",(0,s.jsx)(t.hr,{}),"\n",(0,s.jsx)(t.h3,{id:"4-simulate-the-permutation-test",children:"4. Simulate the permutation test"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-python",children:"n = 500 # Number of simulations.\nstatistics = np.array([]) # Array to keep track of the difference in means for each iteration.\nfor i in np.arange(n): # Run the simulation `n` number of times\n # 1. Shuffle the species.\n shuffled = cats_dogs.assign(Species=np.random.permutation(cats_dogs.get('Species')))\n\n # 2. Compute the test statistic.\n statistic = difference_in_means(shuffled)\n\n # 3. Save the result.\n statistics = np.append(statistics, statistic)\n"})}),"\n",(0,s.jsxs)(t.p,{children:["This code will run the permutation test 500 times, but a different reasonable number can be used instead. It is ",(0,s.jsx)(t.strong,{children:"crucial"})," to keep track of the difference in means each time our for-loop runs so that the number of simulated values can be displayed."]}),"\n",(0,s.jsx)(t.hr,{}),"\n",(0,s.jsx)(t.h3,{id:"5-conclusion",children:"5. Conclusion"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-python",children:'observed = difference_in_means(cats_dogs)\np_value = np.count_nonzero(statistics >= observed) / n\n\nprint("The observed value of the test statistic is:", observed)\nprint("The p-value is:", p_value)\n'})}),"\n",(0,s.jsxs)(t.p,{children:[(0,s.jsx)(t.strong,{children:"The observed value of the test statistic is: 30.361111111111107"})," ",(0,s.jsx)("br",{}),"\n",(0,s.jsx)(t.strong,{children:"The p-value is: 0.004"})]}),"\n",(0,s.jsx)(t.p,{children:"Using a significance level of 0.05:"}),"\n",(0,s.jsx)(t.admonition,{title:"Conclusion",type:"info",children:(0,s.jsxs)(t.ul,{children:["\n",(0,s.jsx)(t.li,{children:"Under the null hypothesis, we rarely see a difference greater than the observed value."}),"\n",(0,s.jsxs)(t.li,{children:["Therefore, we ",(0,s.jsx)(t.strong,{children:"reject"})," the null hypothesis: the evidence implies that the two groups do not come from the same distribution."]}),"\n",(0,s.jsx)(t.li,{children:"Still, we cannot conclude that species causes a different weight because there may be other confounding variables."}),"\n"]})}),"\n",(0,s.jsx)(t.hr,{}),"\n",(0,s.jsx)(t.h3,{id:"6-extra",children:"6. Extra"}),"\n",(0,s.jsx)(t.p,{children:"Let's see how our observed statistic compares to the overall simulated values!"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-python",children:"# Create the histogram.\nbpd.DataFrame().assign(statistics=statistics).plot(kind='hist', bins=20, density=True, ec='w')\n# Don't worry about this line - you won't need to know it for this course!\nplt.axvline(x=observed, c='black', linewidth=4, label='population difference in means')\n"})}),"\n",(0,s.jsx)(t.p,{children:(0,s.jsx)(t.img,{alt:"Distribution",src:n(8803).A+"",width:"576",height:"413"})}),"\n",(0,s.jsxs)(t.p,{children:["From this graph, we can tell that there is barely any data to the ",(0,s.jsx)(t.strong,{children:"right"})," of the black vertical line (our observed test statistic), meaning we have a very low p-value!"]})]})}function p(e={}){const{wrapper:t}={...(0,i.R)(),...e.components};return t?(0,s.jsx)(t,{...e,children:(0,s.jsx)(u,{...e})}):u(e)}},8597:(e,t,n)=>{n.d(t,{A:()=>i});n(6540);var s=n(4848);const i=e=>{let{data:t}=e,n=[],i=[],a="",r=[];if(t){const e=JSON.parse(t);n=e.columns||[],i=e.data||[],a=e.indexName||"Index",r=e.index||[]}return(0,s.jsx)("div",{className:"dataframe-container",children:(0,s.jsxs)("table",{className:"dataframe-table",children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{children:a}),n.map(((e,t)=>(0,s.jsx)("th",{children:e},t)))]})}),(0,s.jsx)("tbody",{children:i.map(((e,t)=>(0,s.jsxs)("tr",{children:[(0,s.jsx)("td",{className:"index-value",children:r[t]}),e.map(((e,t)=>{return(0,s.jsx)("td",{children:(n=e,"boolean"==typeof n?n.toString().charAt(0).toUpperCase()+n.toString().slice(1):n)},t);var n}))]},t)))})]})})}},5158:(e,t,n)=>{n.d(t,{A:()=>a});var s=n(6540),i=n(4848);const a=function(e){let{src:t,sourceLink:n,aspectRatio:a=16/9}=e;const[r,o]=(0,s.useState)(0),[l,c]=(0,s.useState)(0),d=(0,s.useRef)(null);return(0,s.useEffect)((()=>{const e=()=>{if(d.current){const e=d.current.offsetWidth;c(e/a)}};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)}),[a]),(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("div",{ref:d,style:{width:"100%",position:"relative",maxWidth:"100%",backgroundColor:"white"},children:(0,i.jsx)("iframe",{src:t,style:{width:"100%",height:`${l}px`,border:"0",allowFullScreen:!0}},r)}),(0,i.jsx)("div",{style:{display:"flex",justifyContent:"center",margin:"20px 0"},children:(0,i.jsx)("a",{href:n,target:"_blank",rel:"noopener noreferrer",children:"(Source)"})}),(0,i.jsx)("div",{style:{display:"flex",justifyContent:"center",margin:"10px 0"},children:(0,i.jsx)("button",{onClick:()=>{o((e=>e+1))},style:{backgroundColor:"#4CAF50",color:"white",padding:"10px 20px",border:"none",borderRadius:"5px",cursor:"pointer",outline:"none",fontSize:"16px",fontWeight:"bold",boxShadow:"0 4px 8px rgba(0,0,0,0.1)",transition:"background-color 0.3s"},onMouseOver:e=>e.currentTarget.style.backgroundColor="#45a049",onMouseOut:e=>e.currentTarget.style.backgroundColor="#4CAF50",children:"Restart Diagram"})})]})}},8803:(e,t,n)=>{n.d(t,{A:()=>s});const s=n.p+"assets/images/permutation-test-fae4df12733e667b05989b96bf08d9a9.png"},8453:(e,t,n)=>{n.d(t,{R:()=>r,x:()=>o});var s=n(6540);const i={},a=s.createContext(i);function r(e){const t=s.useContext(a);return s.useMemo((function(){return"function"==typeof e?e(t):{...t,...e}}),[t,e])}function o(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:r(e.components),s.createElement(a.Provider,{value:t},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/d4f68316.39fbf26a.js b/assets/js/d4f68316.39fbf26a.js new file mode 100644 index 00000000..a0044e46 --- /dev/null +++ b/assets/js/d4f68316.39fbf26a.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunkbpd_reference=self.webpackChunkbpd_reference||[]).push([[4833],{4520:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>a,contentTitle:()=>i,default:()=>h,frontMatter:()=>s,metadata:()=>c,toc:()=>l});var o=n(4848),r=n(8453);n(8597),n(5158);const s={sidebar_position:1,sidebar_label:"Hypothesis Test vs. Permutation Test",title:"Hypothesis Test vs. Permutation Test"},i=void 0,c={id:"statistical-inference/concept check/hypothesis_vs_permutation",title:"Hypothesis Test vs. Permutation Test",description:"Difference",source:"@site/docs/statistical-inference/concept check/hypothesis_vs_permutation.md",sourceDirName:"statistical-inference/concept check",slug:"/statistical-inference/concept check/hypothesis_vs_permutation",permalink:"/bpd-reference/docs/statistical-inference/concept check/hypothesis_vs_permutation",draft:!1,unlisted:!1,editUrl:"https://github.com/dsc-courses/bpd-reference/tree/main/docs/statistical-inference/concept check/hypothesis_vs_permutation.md",tags:[],version:"current",sidebarPosition:1,frontMatter:{sidebar_position:1,sidebar_label:"Hypothesis Test vs. Permutation Test",title:"Hypothesis Test vs. Permutation Test"},sidebar:"statsSidebar",previous:{title:"Boostrapping and Confidence Intervals",permalink:"/bpd-reference/docs/statistical-inference/bootstrapping"}},a={},l=[{value:"Difference",id:"difference",level:2},{value:"Concept Check \ud83d\udc40",id:"concept-check-",level:2}];function d(e){const t={admonition:"admonition",h2:"h2",li:"li",ol:"ol",p:"p",strong:"strong",ul:"ul",...(0,r.R)(),...e.components},{Details:n}=t;return n||function(e,t){throw new Error("Expected "+(t?"component":"object")+" `"+e+"` to be defined: you likely forgot to import, pass, or provide it.")}("Details",!0),(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(t.h2,{id:"difference",children:"Difference"}),"\n",(0,o.jsx)(t.p,{children:(0,o.jsx)(t.strong,{children:"(Standard) Hypothesis Test"})}),"\n",(0,o.jsxs)(t.ul,{children:["\n",(0,o.jsxs)(t.li,{children:["A ",(0,o.jsx)(t.strong,{children:"population distribution"}),"."]}),"\n",(0,o.jsxs)(t.li,{children:[(0,o.jsx)(t.strong,{children:"One"})," observed ",(0,o.jsx)(t.strong,{children:"sample"}),"."]}),"\n",(0,o.jsx)(t.li,{children:"Answers questions in the form: Does this sample look like it was drawn from the population?"}),"\n"]}),"\n",(0,o.jsx)(t.p,{children:(0,o.jsx)(t.strong,{children:"Permutation Test"})}),"\n",(0,o.jsxs)(t.ul,{children:["\n",(0,o.jsxs)(t.li,{children:[(0,o.jsx)(t.strong,{children:"No"})," information about any ",(0,o.jsx)(t.strong,{children:"population distributions"}),"."]}),"\n",(0,o.jsxs)(t.li,{children:[(0,o.jsx)(t.strong,{children:"Two"})," observed ",(0,o.jsx)(t.strong,{children:"samples"}),"."]}),"\n",(0,o.jsx)(t.li,{children:"Answers questions in the form: Do these two samples look like they were drawn from the same population?"}),"\n"]}),"\n",(0,o.jsx)(t.h2,{id:"concept-check-",children:"Concept Check \ud83d\udc40"}),"\n",(0,o.jsx)(t.p,{children:"Which test do you choose in each of the following scenarios (Hypothesis Test or Permutation Test)?"}),"\n",(0,o.jsxs)(t.ol,{children:["\n",(0,o.jsx)(t.li,{children:"In DSC 10, we ask all students whether they liked labs or homework more. Compare the proportion of students who preferred labs to the proportion who preferred homeworks."}),"\n",(0,o.jsx)(t.li,{children:"Compare the proportion of students from Sixth College who have taken DSC 10 and the proportion of students from Muir College who have taken DSC 10."}),"\n"]}),"\n",(0,o.jsxs)(n,{children:[(0,o.jsx)("summary",{children:"Answer"}),(0,o.jsxs)(t.ol,{children:["\n",(0,o.jsx)(t.li,{children:"Hypothesis Test."}),"\n",(0,o.jsx)(t.li,{children:"Permutation Test."}),"\n"]}),(0,o.jsxs)(t.admonition,{type:"tip",children:[(0,o.jsx)(t.p,{children:"If you can find the proportion of group B by only knowing the proportion of group A, then it is a hypothesis test. For instance, in the first scenario, since we know that DSC 10 students like either labs or homework, we can calculate the proportion of students who preferred labs by subtracting the proportion of students who preferred homework from the whole proportion (100%)."}),(0,o.jsx)(t.p,{children:"However, for the second scenario, we cannot infer one proportion from another. Thus, it is a permutation test."})]})]})]})}function h(e={}){const{wrapper:t}={...(0,r.R)(),...e.components};return t?(0,o.jsx)(t,{...e,children:(0,o.jsx)(d,{...e})}):d(e)}},8597:(e,t,n)=>{n.d(t,{A:()=>r});n(6540);var o=n(4848);const r=e=>{let{data:t}=e,n=[],r=[],s="",i=[];if(t){const e=JSON.parse(t);n=e.columns||[],r=e.data||[],s=e.indexName||"Index",i=e.index||[]}return(0,o.jsx)("div",{className:"dataframe-container",children:(0,o.jsxs)("table",{className:"dataframe-table",children:[(0,o.jsx)("thead",{children:(0,o.jsxs)("tr",{children:[(0,o.jsx)("th",{children:s}),n.map(((e,t)=>(0,o.jsx)("th",{children:e},t)))]})}),(0,o.jsx)("tbody",{children:r.map(((e,t)=>(0,o.jsxs)("tr",{children:[(0,o.jsx)("td",{className:"index-value",children:i[t]}),e.map(((e,t)=>{return(0,o.jsx)("td",{children:(n=e,"boolean"==typeof n?n.toString().charAt(0).toUpperCase()+n.toString().slice(1):n)},t);var n}))]},t)))})]})})}},5158:(e,t,n)=>{n.d(t,{A:()=>s});var o=n(6540),r=n(4848);const s=function(e){let{src:t,sourceLink:n,aspectRatio:s=16/9}=e;const[i,c]=(0,o.useState)(0),[a,l]=(0,o.useState)(0),d=(0,o.useRef)(null);return(0,o.useEffect)((()=>{const e=()=>{if(d.current){const e=d.current.offsetWidth;l(e/s)}};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)}),[s]),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{ref:d,style:{width:"100%",position:"relative",maxWidth:"100%",backgroundColor:"white"},children:(0,r.jsx)("iframe",{src:t,style:{width:"100%",height:`${a}px`,border:"0",allowFullScreen:!0}},i)}),(0,r.jsx)("div",{style:{display:"flex",justifyContent:"center",margin:"20px 0"},children:(0,r.jsx)("a",{href:n,target:"_blank",rel:"noopener noreferrer",children:"(Source)"})}),(0,r.jsx)("div",{style:{display:"flex",justifyContent:"center",margin:"10px 0"},children:(0,r.jsx)("button",{onClick:()=>{c((e=>e+1))},style:{backgroundColor:"#4CAF50",color:"white",padding:"10px 20px",border:"none",borderRadius:"5px",cursor:"pointer",outline:"none",fontSize:"16px",fontWeight:"bold",boxShadow:"0 4px 8px rgba(0,0,0,0.1)",transition:"background-color 0.3s"},onMouseOver:e=>e.currentTarget.style.backgroundColor="#45a049",onMouseOut:e=>e.currentTarget.style.backgroundColor="#4CAF50",children:"Restart Diagram"})})]})}},8453:(e,t,n)=>{n.d(t,{R:()=>i,x:()=>c});var o=n(6540);const r={},s=o.createContext(r);function i(e){const t=o.useContext(s);return o.useMemo((function(){return"function"==typeof e?e(t):{...t,...e}}),[t,e])}function c(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:i(e.components),o.createElement(s.Provider,{value:t},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/d4f68316.a09dc9fc.js b/assets/js/d4f68316.a09dc9fc.js deleted file mode 100644 index fbfa2521..00000000 --- a/assets/js/d4f68316.a09dc9fc.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunkbpd_reference=self.webpackChunkbpd_reference||[]).push([[4833],{4520:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>a,contentTitle:()=>i,default:()=>h,frontMatter:()=>s,metadata:()=>c,toc:()=>l});var o=n(4848),r=n(8453);n(8597),n(5158);const s={sidebar_position:1,sidebar_label:"Hypothesis Test vs. Permutation Test",title:"Hypothesis Test vs. Permutation Test"},i=void 0,c={id:"statistical-inference/concept check/hypothesis_vs_permutation",title:"Hypothesis Test vs. Permutation Test",description:"Difference",source:"@site/docs/statistical-inference/concept check/hypothesis_vs_permutation.md",sourceDirName:"statistical-inference/concept check",slug:"/statistical-inference/concept check/hypothesis_vs_permutation",permalink:"/bpd-reference/docs/statistical-inference/concept check/hypothesis_vs_permutation",draft:!1,unlisted:!1,editUrl:"https://github.com/dsc-courses/bpd-reference/tree/main/docs/statistical-inference/concept check/hypothesis_vs_permutation.md",tags:[],version:"current",sidebarPosition:1,frontMatter:{sidebar_position:1,sidebar_label:"Hypothesis Test vs. Permutation Test",title:"Hypothesis Test vs. Permutation Test"},sidebar:"statsSidebar",previous:{title:"Boostrapping and Confidence Intervals",permalink:"/bpd-reference/docs/statistical-inference/bootstrapping"}},a={},l=[{value:"Difference",id:"difference",level:2},{value:"Concept Check \ud83d\udc40",id:"concept-check-",level:2}];function d(e){const t={admonition:"admonition",h2:"h2",li:"li",ol:"ol",p:"p",strong:"strong",ul:"ul",...(0,r.R)(),...e.components},{Details:n}=t;return n||function(e,t){throw new Error("Expected "+(t?"component":"object")+" `"+e+"` to be defined: you likely forgot to import, pass, or provide it.")}("Details",!0),(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(t.h2,{id:"difference",children:"Difference"}),"\n",(0,o.jsx)(t.p,{children:(0,o.jsx)(t.strong,{children:"Hypothesis Testing"})}),"\n",(0,o.jsxs)(t.ul,{children:["\n",(0,o.jsxs)(t.li,{children:["A ",(0,o.jsx)(t.strong,{children:"population distribution"}),"."]}),"\n",(0,o.jsxs)(t.li,{children:[(0,o.jsx)(t.strong,{children:"One"})," observed ",(0,o.jsx)(t.strong,{children:"sample"}),"."]}),"\n",(0,o.jsx)(t.li,{children:"Answers questions in the form: Does this sample look like it was drawn from the population?"}),"\n"]}),"\n",(0,o.jsx)(t.p,{children:(0,o.jsx)(t.strong,{children:"Permutation Testing"})}),"\n",(0,o.jsxs)(t.ul,{children:["\n",(0,o.jsxs)(t.li,{children:[(0,o.jsx)(t.strong,{children:"No"})," information about any ",(0,o.jsx)(t.strong,{children:"population distributions"}),"."]}),"\n",(0,o.jsxs)(t.li,{children:[(0,o.jsx)(t.strong,{children:"Two"})," observed ",(0,o.jsx)(t.strong,{children:"samples"}),"."]}),"\n",(0,o.jsx)(t.li,{children:"Answers questions in the form: Do these two samples look like they were drawn from the same population?"}),"\n"]}),"\n",(0,o.jsx)(t.h2,{id:"concept-check-",children:"Concept Check \ud83d\udc40"}),"\n",(0,o.jsx)(t.p,{children:"Which test do you choose in each of the following scenarios (Hypothesis Test or Permutation Test)?"}),"\n",(0,o.jsxs)(t.ol,{children:["\n",(0,o.jsx)(t.li,{children:"In DSC 10, we ask all students whether they liked labs or homework more. Compare the proportion of students who preferred labs to the proportion who preferred homeworks."}),"\n",(0,o.jsx)(t.li,{children:"Compare the proportion of students from Sixth College who have taken DSC 10 and the proportion of students from Muir College who have taken DSC 10."}),"\n"]}),"\n",(0,o.jsxs)(n,{children:[(0,o.jsx)("summary",{children:"Answer"}),(0,o.jsxs)(t.ol,{children:["\n",(0,o.jsx)(t.li,{children:"Hypothesis Test."}),"\n",(0,o.jsx)(t.li,{children:"Permutation Test."}),"\n"]}),(0,o.jsxs)(t.admonition,{type:"tip",children:[(0,o.jsx)(t.p,{children:"If you can find the proportion of group B by only knowing the proportion of group A, then it is a hypothesis test. For instance, in the first scenario, since we know that DSC 10 students like either labs or homework, we can calculate the proportion of students who preferred labs by subtracting the proportion of students who preferred homework from the whole proportion (100%)."}),(0,o.jsx)(t.p,{children:"However, for the second scenario, we cannot infer one proportion from another. Thus, it is a permutation test."})]})]})]})}function h(e={}){const{wrapper:t}={...(0,r.R)(),...e.components};return t?(0,o.jsx)(t,{...e,children:(0,o.jsx)(d,{...e})}):d(e)}},8597:(e,t,n)=>{n.d(t,{A:()=>r});n(6540);var o=n(4848);const r=e=>{let{data:t}=e,n=[],r=[],s="",i=[];if(t){const e=JSON.parse(t);n=e.columns||[],r=e.data||[],s=e.indexName||"Index",i=e.index||[]}return(0,o.jsx)("div",{className:"dataframe-container",children:(0,o.jsxs)("table",{className:"dataframe-table",children:[(0,o.jsx)("thead",{children:(0,o.jsxs)("tr",{children:[(0,o.jsx)("th",{children:s}),n.map(((e,t)=>(0,o.jsx)("th",{children:e},t)))]})}),(0,o.jsx)("tbody",{children:r.map(((e,t)=>(0,o.jsxs)("tr",{children:[(0,o.jsx)("td",{className:"index-value",children:i[t]}),e.map(((e,t)=>{return(0,o.jsx)("td",{children:(n=e,"boolean"==typeof n?n.toString().charAt(0).toUpperCase()+n.toString().slice(1):n)},t);var n}))]},t)))})]})})}},5158:(e,t,n)=>{n.d(t,{A:()=>s});var o=n(6540),r=n(4848);const s=function(e){let{src:t,sourceLink:n,aspectRatio:s=16/9}=e;const[i,c]=(0,o.useState)(0),[a,l]=(0,o.useState)(0),d=(0,o.useRef)(null);return(0,o.useEffect)((()=>{const e=()=>{if(d.current){const e=d.current.offsetWidth;l(e/s)}};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)}),[s]),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{ref:d,style:{width:"100%",position:"relative",maxWidth:"100%",backgroundColor:"white"},children:(0,r.jsx)("iframe",{src:t,style:{width:"100%",height:`${a}px`,border:"0",allowFullScreen:!0}},i)}),(0,r.jsx)("div",{style:{display:"flex",justifyContent:"center",margin:"20px 0"},children:(0,r.jsx)("a",{href:n,target:"_blank",rel:"noopener noreferrer",children:"(Source)"})}),(0,r.jsx)("div",{style:{display:"flex",justifyContent:"center",margin:"10px 0"},children:(0,r.jsx)("button",{onClick:()=>{c((e=>e+1))},style:{backgroundColor:"#4CAF50",color:"white",padding:"10px 20px",border:"none",borderRadius:"5px",cursor:"pointer",outline:"none",fontSize:"16px",fontWeight:"bold",boxShadow:"0 4px 8px rgba(0,0,0,0.1)",transition:"background-color 0.3s"},onMouseOver:e=>e.currentTarget.style.backgroundColor="#45a049",onMouseOut:e=>e.currentTarget.style.backgroundColor="#4CAF50",children:"Restart Diagram"})})]})}},8453:(e,t,n)=>{n.d(t,{R:()=>i,x:()=>c});var o=n(6540);const r={},s=o.createContext(r);function i(e){const t=o.useContext(s);return o.useMemo((function(){return"function"==typeof e?e(t):{...t,...e}}),[t,e])}function c(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:i(e.components),o.createElement(s.Provider,{value:t},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/f03ae67e.4876c58e.js b/assets/js/f03ae67e.4876c58e.js new file mode 100644 index 00000000..236421d7 --- /dev/null +++ b/assets/js/f03ae67e.4876c58e.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunkbpd_reference=self.webpackChunkbpd_reference||[]).push([[972],{3007:(e,t,s)=>{s.r(t),s.d(t,{assets:()=>h,contentTitle:()=>a,default:()=>p,frontMatter:()=>r,metadata:()=>l,toc:()=>c});var n=s(4848),i=s(8453),o=s(8597);s(5158);const r={sidebar_position:6,sidebar_label:"Hypothesis Test",title:"Hypothesis Test",tags:["querying","functions","for-loop","histogram"]},a=void 0,l={id:"statistical-inference/hypothesis_test",title:"Hypothesis Test",description:"Concept",source:"@site/docs/statistical-inference/hypothesis_test.md",sourceDirName:"statistical-inference",slug:"/statistical-inference/hypothesis_test",permalink:"/bpd-reference/docs/statistical-inference/hypothesis_test",draft:!1,unlisted:!1,editUrl:"https://github.com/dsc-courses/bpd-reference/tree/main/docs/statistical-inference/hypothesis_test.md",tags:[{label:"querying",permalink:"/bpd-reference/docs/tags/querying"},{label:"functions",permalink:"/bpd-reference/docs/tags/functions"},{label:"for-loop",permalink:"/bpd-reference/docs/tags/for-loop"},{label:"histogram",permalink:"/bpd-reference/docs/tags/histogram"}],version:"current",sidebarPosition:6,frontMatter:{sidebar_position:6,sidebar_label:"Hypothesis Test",title:"Hypothesis Test",tags:["querying","functions","for-loop","histogram"]},sidebar:"statsSidebar",previous:{title:"P-value",permalink:"/bpd-reference/docs/statistical-inference/p_value"},next:{title:"Permutation Test",permalink:"/bpd-reference/docs/statistical-inference/permutation_test"}},h={},c=[{value:"Concept",id:"concept",level:2},{value:"Code Example 1 (Difference)",id:"code-example-1-difference",level:2},{value:"1. State the question/hypothesis",id:"1-state-the-questionhypothesis",level:3},{value:"2. Calculate the overall proportion",id:"2-calculate-the-overall-proportion",level:3},{value:"3. Create a function to calculate test statistic",id:"3-create-a-function-to-calculate-test-statistic",level:3},{value:"4. Compute the observed statistic",id:"4-compute-the-observed-statistic",level:3},{value:"5. Simulate the hypothesis test under the null hypothesis",id:"5-simulate-the-hypothesis-test-under-the-null-hypothesis",level:3},{value:"6. Conclusion",id:"6-conclusion",level:3},{value:"7. Extra",id:"7-extra",level:3},{value:"Code Example 2 (TVD)",id:"code-example-2-tvd",level:2},{value:"1. State the question/hypothesis",id:"1-state-the-questionhypothesis-1",level:3},{value:"2. Create a function to calculate test statistic (TVD)",id:"2-create-a-function-to-calculate-test-statistic-tvd",level:3},{value:"4. Compute the observed statistic",id:"4-compute-the-observed-statistic-1",level:3},{value:"5. Simulate the hypothesis test under the null hypothesis",id:"5-simulate-the-hypothesis-test-under-the-null-hypothesis-1",level:3},{value:"6. Conclusion",id:"6-conclusion-1",level:3},{value:"7. Extra",id:"7-extra-1",level:3}];function d(e){const t={admonition:"admonition",annotation:"annotation",code:"code",em:"em",h2:"h2",h3:"h3",hr:"hr",img:"img",li:"li",math:"math",mo:"mo",mrow:"mrow",ol:"ol",p:"p",pre:"pre",semantics:"semantics",span:"span",strong:"strong",ul:"ul",...(0,i.R)(),...e.components};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(t.h2,{id:"concept",children:"Concept"}),"\n",(0,n.jsx)(t.admonition,{title:"Note \ud83c\udf1f",type:"note",children:(0,n.jsxs)(t.p,{children:["This page refers to the ",(0,n.jsx)(t.strong,{children:"standard"})," hypothesis test."]})}),"\n",(0,n.jsx)(t.admonition,{title:"Key Idea",type:"tip",children:(0,n.jsx)(t.p,{children:"We use a hypothesis test to test whether a sample was drawn from a population."})}),"\n",(0,n.jsxs)(t.admonition,{title:"Terminology",type:"info",children:[(0,n.jsxs)(t.p,{children:[(0,n.jsx)(t.strong,{children:"Hypothesis Test"}),": A process that test whether a sample was drawn from a population, given a population distribution and a sample."]}),(0,n.jsx)(t.p,{children:"To conduct a hypothesis test:"}),(0,n.jsxs)(t.ol,{children:["\n",(0,n.jsx)(t.li,{children:"Simulate the experiment many times under the assumption that the null hypothesis is true."}),"\n",(0,n.jsx)(t.li,{children:"Compute a test statistic on each of the simulated samples, as well as on the observed sample."}),"\n",(0,n.jsx)(t.li,{children:"Look at the resulting empirical distribution of test statistics and see where the observed test statistic falls. If it seems like an atypical value (too large or too small), we reject the null hypothesis; otherwise, we fail to reject the null."}),"\n"]})]}),"\n",(0,n.jsx)(t.hr,{}),"\n",(0,n.jsx)(t.h2,{id:"code-example-1-difference",children:"Code Example 1 (Difference)"}),"\n",(0,n.jsx)(t.h3,{id:"1-state-the-questionhypothesis",children:"1. State the question/hypothesis"}),"\n",(0,n.jsxs)(t.admonition,{title:"Hypotheses",type:"info",children:[(0,n.jsx)(t.p,{children:"We will test the following pair of hypotheses at the standard p = 0.05 significance level."}),(0,n.jsxs)(t.ul,{children:["\n",(0,n.jsxs)(t.li,{children:[(0,n.jsx)(t.strong,{children:"Null Hypothesis:"}),' The proportion of "white" dogs among dogs is ',(0,n.jsx)(t.strong,{children:"equal"}),' to the proportion of "white" pets in the overall population.']}),"\n",(0,n.jsxs)(t.li,{children:[(0,n.jsx)(t.strong,{children:"Alternative Hypothesis:"}),' The distribution of "white" dogs among dogs is ',(0,n.jsx)(t.strong,{children:"greater than"}),' the proportion of "white" pets in the overall population.']}),"\n"]})]}),"\n",(0,n.jsxs)(t.p,{children:['Since the alternative hypothesis is of the form "A is ',(0,n.jsx)(t.strong,{children:(0,n.jsx)(t.em,{children:"greater than"})}),' B," the ',(0,n.jsx)(t.strong,{children:"test statistic"})," should measure ",(0,n.jsx)(t.strong,{children:"signed difference"})," rather than absolute difference."]}),"\n",(0,n.jsxs)(t.p,{children:[(0,n.jsxs)(t.span,{className:"katex",children:[(0,n.jsx)(t.span,{className:"katex-mathml",children:(0,n.jsx)(t.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,n.jsxs)(t.semantics,{children:[(0,n.jsx)(t.mrow,{children:(0,n.jsx)(t.mo,{children:"\u2234"})}),(0,n.jsx)(t.annotation,{encoding:"application/x-tex",children:"\\therefore"})]})})}),(0,n.jsx)(t.span,{className:"katex-html","aria-hidden":"true",children:(0,n.jsxs)(t.span,{className:"base",children:[(0,n.jsx)(t.span,{className:"strut",style:{height:"0.6922em"}}),(0,n.jsx)(t.span,{className:"mrel amsrm",children:"\u2234"})]})})]})," We use ",(0,n.jsx)(t.strong,{children:"the difference in proportions"})," of white dogs among dogs and white pets in the overall poplulation as the test statistic."]}),"\n",(0,n.jsx)(t.hr,{}),"\n",(0,n.jsx)(t.h3,{id:"2-calculate-the-overall-proportion",children:"2. Calculate the overall proportion"}),"\n",(0,n.jsx)(t.p,{children:"We first compute the proportion of white pets in the overall population, which will be used for calculating the test statistic."}),"\n",(0,n.jsx)(t.pre,{children:(0,n.jsx)(t.code,{className:"language-python",children:"#Method 1: Obtain a series of boolean values (1s and 0s), and calculate the mean\noverall_prop = (full_pets.get('Color')=='white').mean()\n\n#Method 2: Query the DataFrame and obtain the proportion by using .shape[0]\n#overall_prop = full_pets[full_pets.get('Color')=='white'].shape[0]/full_pets.shape[0]\n\noverall_prop\n"})}),"\n",(0,n.jsx)(t.p,{children:"0.2631578947368421"}),"\n",(0,n.jsx)(t.hr,{}),"\n",(0,n.jsx)(t.h3,{id:"3-create-a-function-to-calculate-test-statistic",children:"3. Create a function to calculate test statistic"}),"\n",(0,n.jsx)(t.p,{children:"Create a function to calculate the test statistic during every trial of our hypothesis test."}),"\n",(0,n.jsx)(t.pre,{children:(0,n.jsx)(t.code,{className:"language-python",children:'def difference_in_proportions(dogs_prop, overall_prop):\n """\n Calculate the difference in proportions of white dogs among dogs and white pets in the overall population.\n ---\n Input:\n dogs_prop: the proportion of white dogs among all dogs.\n overall_prop: the proportion of white pets in the overall population.\n ---\n Output:\n The difference in proportions of white dogs among dogs and white pets in the overall population.\n """\n return dogs_prop - overall_prop\n'})}),"\n",(0,n.jsx)(t.p,{children:(0,n.jsx)(t.em,{children:"Note: Although we can simply do this in the for-loop shown in the next step, we can practice good coding habits by separating our code into readable bits!"})}),"\n",(0,n.jsx)(t.hr,{}),"\n",(0,n.jsx)(t.h3,{id:"4-compute-the-observed-statistic",children:"4. Compute the observed statistic"}),"\n",(0,n.jsx)(t.pre,{children:(0,n.jsx)(t.code,{className:"language-python",children:"# Query the DataFrame to only include dogs\ndogs_df = full_pets[full_pets.get('Species') == 'dog']\n# Compute the observed proportion of white dogs among all dogs\nobs_dogs_prop = (dogs_df.get('Color') == 'white').mean()\n# Calculate the observed statistic\nobserved_stat = difference_in_proportions(obs_dogs_prop, overall_prop)\nobserved_stat\n"})}),"\n",(0,n.jsx)(t.p,{children:"0.18128654970760233"}),"\n",(0,n.jsx)(t.hr,{}),"\n",(0,n.jsx)(t.h3,{id:"5-simulate-the-hypothesis-test-under-the-null-hypothesis",children:"5. Simulate the hypothesis test under the null hypothesis"}),"\n",(0,n.jsx)(t.pre,{children:(0,n.jsx)(t.code,{className:"language-python",children:'n = 500 # Number of simulations.\ntest_statistics = np.array([]) # Array to keep track of the test statistic for each iteration.\n\n# Calculte the smaple size (number of dogs)\nsample_size = dogs_df.shape[0]\n\n# Under the null hypothesis, proportion of "white" dogs among dogs is equal to the proportion of white pets among the overall population\nmodel_proportions = np.array([obs_dogs_prop, 1-obs_dogs_prop]) \n\nfor i in np.arange(n): # Run the simulation `n` number of times\n \n # 1. Simulate the dogs distribution\n # Calculate the the proportion of white dogs among all dogs.\n simulation_proportion = np.random.multinomial(sample_size, model_proportions)[0] / sample_size\n \n # 2. Compute the test statistic\n test_stat = difference_in_proportions(simulation_proportion, overall_prop)\n\n # 3. Save the result\n test_statistics = np.append(test_statistics, test_stat)\n'})}),"\n",(0,n.jsxs)(t.p,{children:["This code will run the hypothesis test 500 times, but a different reasonable number can be used instead. It is ",(0,n.jsx)(t.strong,{children:"crucial"})," to keep track of the test statistic each time our for-loop runs so that the number of simulated values can be stored."]}),"\n",(0,n.jsx)(t.hr,{}),"\n",(0,n.jsx)(t.h3,{id:"6-conclusion",children:"6. Conclusion"}),"\n",(0,n.jsx)(t.pre,{children:(0,n.jsx)(t.code,{className:"language-python",children:'p_value = np.count_nonzero(test_statistics >= observed_stat) / n\n\nprint("The observed value of the test statistic is:", observed_stat)\nprint("The p-value is:", p_value)\n'})}),"\n",(0,n.jsxs)(t.p,{children:[(0,n.jsx)(t.strong,{children:"The observed value of the test statistic is:"})," 0.18128654970760233 ",(0,n.jsx)("br",{}),"\n",(0,n.jsx)(t.strong,{children:"The p-value is:"})," 0.616"]}),"\n",(0,n.jsx)(t.p,{children:"Using a significance level of 0.05:"}),"\n",(0,n.jsx)(t.admonition,{title:"Conclusion",type:"info",children:(0,n.jsxs)(t.ul,{children:["\n",(0,n.jsx)(t.li,{children:"Under the null hypothesis, there is a sufficiently large probability of seeing a difference greater than the observed value. The data are consistent with the null hypothesis."}),"\n",(0,n.jsxs)(t.li,{children:["Since our p-value is greater than 0.05, we ",(0,n.jsx)(t.strong,{children:"fail to reject"})," the null hypothesis."]}),"\n"]})}),"\n",(0,n.jsx)(t.hr,{}),"\n",(0,n.jsx)(t.h3,{id:"7-extra",children:"7. Extra"}),"\n",(0,n.jsx)(t.p,{children:"Let's see how our observed statistic compares to the overall simulated values!"}),"\n",(0,n.jsx)(t.pre,{children:(0,n.jsx)(t.code,{className:"language-python",children:"# Create the histogram.\nbpd.DataFrame().assign(test_statistics=test_statistics).plot(kind='hist', bins= 10, density=True, ec='w')\n# Don't worry about these lines - you won't need to know it for this course!\nplt.axvline(x=observed_stat, c='black', linewidth=4);\nyticks = plt.gca().get_yticks()\nplt.yticks(yticks, np.round(yticks * 0.1, 2))\nplt.show()\n"})}),"\n",(0,n.jsx)(t.p,{children:(0,n.jsx)(t.img,{alt:"Distribution",src:s(2527).A+"",width:"640",height:"480"})}),"\n",(0,n.jsxs)(t.p,{children:["From this graph, we can see that more than half of the data are to the ",(0,n.jsx)(t.strong,{children:"right"})," of the black vertical line (our observed statistic), meaning we have a relatively high p-value!"]}),"\n",(0,n.jsx)(t.hr,{}),"\n",(0,n.jsx)(t.h2,{id:"code-example-2-tvd",children:"Code Example 2 (TVD)"}),"\n",(0,n.jsx)(t.h3,{id:"1-state-the-questionhypothesis-1",children:"1. State the question/hypothesis"}),"\n",(0,n.jsx)(t.p,{children:"We found that the color distribution of dogs seems different from that of all pets."}),"\n",(0,n.jsx)(o.A,{data:'{"columns":["Pets_Dist","Dogs_Dist"],"index":["black","golden","white"],"data":[[0.53,0.44],[0.21,0.12],[0.26,0.44]]}'}),"\n",(0,n.jsx)(t.p,{children:"To see whether this difference is due to random chance, we will test the following pair of hypotheses at the standard p = 0.05 significance level."}),"\n",(0,n.jsx)(t.admonition,{title:"Hypotheses",type:"info",children:(0,n.jsxs)(t.ul,{children:["\n",(0,n.jsxs)(t.li,{children:[(0,n.jsx)(t.strong,{children:"Null Hypothesis:"})," The color distribution of dogs is the ",(0,n.jsx)(t.strong,{children:"same as"})," the color distribution of pets."]}),"\n",(0,n.jsxs)(t.li,{children:[(0,n.jsx)(t.strong,{children:"Alternative Hypothesis:"})," The color distribution of dogs is ",(0,n.jsx)(t.strong,{children:"different from"})," the color distribution of pets."]}),"\n"]})}),"\n",(0,n.jsxs)(t.p,{children:["Since we are comparing two ",(0,n.jsx)(t.strong,{children:"categorical"})," distributions, we use Total Variation Distance (TVD) between the two distributions as our ",(0,n.jsx)(t.strong,{children:"test statistic"}),"."]}),"\n",(0,n.jsx)(t.hr,{}),"\n",(0,n.jsx)(t.h3,{id:"2-create-a-function-to-calculate-test-statistic-tvd",children:"2. Create a function to calculate test statistic (TVD)"}),"\n",(0,n.jsx)(t.p,{children:"Create a function to calculate the test statistic during every trial of our hypothesis test."}),"\n",(0,n.jsx)(t.pre,{children:(0,n.jsx)(t.code,{className:"language-python",children:"def total_variation_distance(dist1, dist2):\n '''Computes the TVD between two categorical distributions, \n assuming the categories appear in the same order.'''\n return np.abs((dist1 - dist2)).sum() / 2\n"})}),"\n",(0,n.jsx)(t.hr,{}),"\n",(0,n.jsx)(t.h3,{id:"4-compute-the-observed-statistic-1",children:"4. Compute the observed statistic"}),"\n",(0,n.jsx)(t.pre,{children:(0,n.jsx)(t.code,{className:"language-python",children:"pets_color_dist = np.array([0.53, 0.21, 0.26])\ndogs_color_dist = np.array([0.44, 0.12, 0.44])\nobserved_tvd = total_variation_distance(dogs_color_dist, pets_color_dist)\nobserved_tvd\n"})}),"\n",(0,n.jsx)(t.p,{children:"0.18"}),"\n",(0,n.jsx)(t.hr,{}),"\n",(0,n.jsx)(t.h3,{id:"5-simulate-the-hypothesis-test-under-the-null-hypothesis-1",children:"5. Simulate the hypothesis test under the null hypothesis"}),"\n",(0,n.jsx)(t.pre,{children:(0,n.jsx)(t.code,{className:"language-python",children:"n = 5000 # Number of simulations.\ntvds = np.array([]) # Array to keep track of the test statistic for each iteration.\n\n# Get sample df (dogs df)\ndog_df = full_pets[full_pets.get('Species') == 'dog'] \n\n# Calculte the smaple size (number of dogs)\nsample_size = dog_df.shape[0]\n\nfor i in np.arange(n): # Run the simulation `n` number of times\n \n # 1. Simulate the color distribution of dogs.\n # Under the null hypothesis, color distribution of dogs should be equal to the color distribution of pets among the overall population\n sample_distribution = np.random.multinomial(sample_size, pets_color_dist) / sample_size\n\n # 2. Compute the test statistic (TVD)\n new_tvd = total_variation_distance(sample_distribution, pets_color_dist)\n\n # 3. Save the result\n tvds = np.append(tvds, new_tvd)\n"})}),"\n",(0,n.jsxs)(t.p,{children:["This code will run the hypothesis test 5000 times, but a different reasonable number can be used instead. It is ",(0,n.jsx)(t.strong,{children:"crucial"})," to keep track of the test statistic each time our for-loop runs so that the number of simulated values can be stored."]}),"\n",(0,n.jsx)(t.hr,{}),"\n",(0,n.jsx)(t.h3,{id:"6-conclusion-1",children:"6. Conclusion"}),"\n",(0,n.jsx)(t.pre,{children:(0,n.jsx)(t.code,{className:"language-python",children:'p_value = np.count_nonzero(tvds >= observed_tvd) / n\n\nprint("The observed value of the test statistic is:", observed_tvd)\nprint("The p-value is:", p_value)\n'})}),"\n",(0,n.jsxs)(t.p,{children:[(0,n.jsx)(t.strong,{children:"The observed value of the test statistic is:"})," 0.18",(0,n.jsx)("br",{}),"\n",(0,n.jsx)(t.strong,{children:"The p-value is:"})," 0.4972"]}),"\n",(0,n.jsx)(t.p,{children:"Using a significance level of 0.05:"}),"\n",(0,n.jsx)(t.admonition,{title:"Conclusion",type:"info",children:(0,n.jsxs)(t.ul,{children:["\n",(0,n.jsx)(t.li,{children:"Under the null hypothesis, there is a sufficiently large probability of seeing a difference greater than the observed value. The data are consistent with the null hypothesis."}),"\n",(0,n.jsxs)(t.li,{children:["Since our p-value is greater than 0.05, we ",(0,n.jsx)(t.strong,{children:"fail to reject"})," the null hypothesis."]}),"\n"]})}),"\n",(0,n.jsx)(t.hr,{}),"\n",(0,n.jsx)(t.h3,{id:"7-extra-1",children:"7. Extra"}),"\n",(0,n.jsx)(t.p,{children:"Let's see how our observed statistic compares to the overall simulated values!"}),"\n",(0,n.jsx)(t.pre,{children:(0,n.jsx)(t.code,{className:"language-python",children:"# Create the histogram.\nbpd.DataFrame().assign(tvds=tvds).plot(kind='hist', density=True, bins=20, ec='w', figsize=(10, 5), title='Empirical Distribution of TVD Between Pets Colors and Dogs Colors')\n# Don't worry about these lines - you won't need to know it for this course!\nplt.axvline(observed_tvd, color='black', linewidth=4, label='Observed Statistic')\nplt.legend();\n"})}),"\n",(0,n.jsx)(t.p,{children:(0,n.jsx)(t.img,{alt:"Distribution",src:s(3965).A+"",width:"1000",height:"500"})}),"\n",(0,n.jsxs)(t.p,{children:["From this graph, we can see that almost half of the data are to the ",(0,n.jsx)(t.strong,{children:"right"})," of the black vertical line (our observed statistic), meaning we have a relatively high p-value!"]})]})}function p(e={}){const{wrapper:t}={...(0,i.R)(),...e.components};return t?(0,n.jsx)(t,{...e,children:(0,n.jsx)(d,{...e})}):d(e)}},8597:(e,t,s)=>{s.d(t,{A:()=>i});s(6540);var n=s(4848);const i=e=>{let{data:t}=e,s=[],i=[],o="",r=[];if(t){const e=JSON.parse(t);s=e.columns||[],i=e.data||[],o=e.indexName||"Index",r=e.index||[]}return(0,n.jsx)("div",{className:"dataframe-container",children:(0,n.jsxs)("table",{className:"dataframe-table",children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{children:o}),s.map(((e,t)=>(0,n.jsx)("th",{children:e},t)))]})}),(0,n.jsx)("tbody",{children:i.map(((e,t)=>(0,n.jsxs)("tr",{children:[(0,n.jsx)("td",{className:"index-value",children:r[t]}),e.map(((e,t)=>{return(0,n.jsx)("td",{children:(s=e,"boolean"==typeof s?s.toString().charAt(0).toUpperCase()+s.toString().slice(1):s)},t);var s}))]},t)))})]})})}},5158:(e,t,s)=>{s.d(t,{A:()=>o});var n=s(6540),i=s(4848);const o=function(e){let{src:t,sourceLink:s,aspectRatio:o=16/9}=e;const[r,a]=(0,n.useState)(0),[l,h]=(0,n.useState)(0),c=(0,n.useRef)(null);return(0,n.useEffect)((()=>{const e=()=>{if(c.current){const e=c.current.offsetWidth;h(e/o)}};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)}),[o]),(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("div",{ref:c,style:{width:"100%",position:"relative",maxWidth:"100%",backgroundColor:"white"},children:(0,i.jsx)("iframe",{src:t,style:{width:"100%",height:`${l}px`,border:"0",allowFullScreen:!0}},r)}),(0,i.jsx)("div",{style:{display:"flex",justifyContent:"center",margin:"20px 0"},children:(0,i.jsx)("a",{href:s,target:"_blank",rel:"noopener noreferrer",children:"(Source)"})}),(0,i.jsx)("div",{style:{display:"flex",justifyContent:"center",margin:"10px 0"},children:(0,i.jsx)("button",{onClick:()=>{a((e=>e+1))},style:{backgroundColor:"#4CAF50",color:"white",padding:"10px 20px",border:"none",borderRadius:"5px",cursor:"pointer",outline:"none",fontSize:"16px",fontWeight:"bold",boxShadow:"0 4px 8px rgba(0,0,0,0.1)",transition:"background-color 0.3s"},onMouseOver:e=>e.currentTarget.style.backgroundColor="#45a049",onMouseOut:e=>e.currentTarget.style.backgroundColor="#4CAF50",children:"Restart Diagram"})})]})}},2527:(e,t,s)=>{s.d(t,{A:()=>n});const n=s.p+"assets/images/hypothesis-test-776f8723e19318f4f91020489482dcf5.png"},3965:(e,t,s)=>{s.d(t,{A:()=>n});const n=s.p+"assets/images/hypothesis-test2-7615aa5325b73c6c19541b78e2619a30.png"},8453:(e,t,s)=>{s.d(t,{R:()=>r,x:()=>a});var n=s(6540);const i={},o=n.createContext(i);function r(e){const t=n.useContext(o);return n.useMemo((function(){return"function"==typeof e?e(t):{...t,...e}}),[t,e])}function a(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:r(e.components),n.createElement(o.Provider,{value:t},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/f03ae67e.fff9d33b.js b/assets/js/f03ae67e.fff9d33b.js deleted file mode 100644 index 9c56056b..00000000 --- a/assets/js/f03ae67e.fff9d33b.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunkbpd_reference=self.webpackChunkbpd_reference||[]).push([[972],{3007:(e,t,s)=>{s.r(t),s.d(t,{assets:()=>h,contentTitle:()=>a,default:()=>p,frontMatter:()=>r,metadata:()=>l,toc:()=>c});var n=s(4848),i=s(8453),o=s(8597);s(5158);const r={sidebar_position:6,sidebar_label:"Hypothesis Test",title:"Hypothesis Test",tags:["querying","functions","for-loop","histogram"]},a=void 0,l={id:"statistical-inference/hypothesis_test",title:"Hypothesis Test",description:"Concept",source:"@site/docs/statistical-inference/hypothesis_test.md",sourceDirName:"statistical-inference",slug:"/statistical-inference/hypothesis_test",permalink:"/bpd-reference/docs/statistical-inference/hypothesis_test",draft:!1,unlisted:!1,editUrl:"https://github.com/dsc-courses/bpd-reference/tree/main/docs/statistical-inference/hypothesis_test.md",tags:[{label:"querying",permalink:"/bpd-reference/docs/tags/querying"},{label:"functions",permalink:"/bpd-reference/docs/tags/functions"},{label:"for-loop",permalink:"/bpd-reference/docs/tags/for-loop"},{label:"histogram",permalink:"/bpd-reference/docs/tags/histogram"}],version:"current",sidebarPosition:6,frontMatter:{sidebar_position:6,sidebar_label:"Hypothesis Test",title:"Hypothesis Test",tags:["querying","functions","for-loop","histogram"]},sidebar:"statsSidebar",previous:{title:"P-value",permalink:"/bpd-reference/docs/statistical-inference/p_value"},next:{title:"Permutation Test",permalink:"/bpd-reference/docs/statistical-inference/permutation_test"}},h={},c=[{value:"Concept",id:"concept",level:2},{value:"Code Example 1 (Difference)",id:"code-example-1-difference",level:2},{value:"1. State the question/hypothesis",id:"1-state-the-questionhypothesis",level:3},{value:"2. Calculate the overall proportion",id:"2-calculate-the-overall-proportion",level:3},{value:"3. Create a function to calculate test statistic",id:"3-create-a-function-to-calculate-test-statistic",level:3},{value:"4. Compute the observed statistic",id:"4-compute-the-observed-statistic",level:3},{value:"5. Simulate the hypothesis test under the null hypothesis",id:"5-simulate-the-hypothesis-test-under-the-null-hypothesis",level:3},{value:"6. Conclusion",id:"6-conclusion",level:3},{value:"7. Extra",id:"7-extra",level:3},{value:"Code Example 2 (TVD)",id:"code-example-2-tvd",level:2},{value:"1. State the question/hypothesis",id:"1-state-the-questionhypothesis-1",level:3}];function d(e){const t={admonition:"admonition",annotation:"annotation",code:"code",em:"em",h2:"h2",h3:"h3",hr:"hr",img:"img",li:"li",math:"math",mo:"mo",mrow:"mrow",ol:"ol",p:"p",pre:"pre",semantics:"semantics",span:"span",strong:"strong",ul:"ul",...(0,i.R)(),...e.components};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(t.h2,{id:"concept",children:"Concept"}),"\n",(0,n.jsx)(t.admonition,{title:"Key Idea",type:"tip",children:(0,n.jsx)(t.p,{children:"We use a hypothesis test to test whether a sample was drawn from a population."})}),"\n",(0,n.jsxs)(t.admonition,{title:"Terminology",type:"info",children:[(0,n.jsxs)(t.p,{children:[(0,n.jsx)(t.strong,{children:"Hypothesis Test"}),": A process that test whether a sample was drawn from a population, given a population distribution and a sample."]}),(0,n.jsx)(t.p,{children:"To conduct a hypothesis test:"}),(0,n.jsxs)(t.ol,{children:["\n",(0,n.jsx)(t.li,{children:"Simulate the experiment many times under the assumption that the null hypothesis is true."}),"\n",(0,n.jsx)(t.li,{children:"Compute a test statistic on each of the simulated samples, as well as on the observed sample."}),"\n",(0,n.jsx)(t.li,{children:"Look at the resulting empirical distribution of test statistics and see where the observed test statistic falls. If it seems like an atypical value (too large or too small), we reject the null hypothesis; otherwise, we fail to reject the null."}),"\n"]})]}),"\n",(0,n.jsx)(t.hr,{}),"\n",(0,n.jsx)(t.h2,{id:"code-example-1-difference",children:"Code Example 1 (Difference)"}),"\n",(0,n.jsx)(t.h3,{id:"1-state-the-questionhypothesis",children:"1. State the question/hypothesis"}),"\n",(0,n.jsxs)(t.admonition,{title:"Hypotheses",type:"info",children:[(0,n.jsx)(t.p,{children:"We will test the following pair of hypotheses at the standard p = 0.05 significance level."}),(0,n.jsxs)(t.ul,{children:["\n",(0,n.jsxs)(t.li,{children:[(0,n.jsx)(t.strong,{children:"Null Hypothesis:"}),' The proportion of "white" dogs among dogs is ',(0,n.jsx)(t.strong,{children:"equal"}),' to the proportion of "white" pets in the overall population.']}),"\n",(0,n.jsxs)(t.li,{children:[(0,n.jsx)(t.strong,{children:"Alternative Hypothesis:"}),' The distribution of "white" dogs among dogs is ',(0,n.jsx)(t.strong,{children:"greater than"}),' the proportion of "white" pets in the overall population.']}),"\n"]})]}),"\n",(0,n.jsxs)(t.p,{children:['Since the alternative hypothesis is of the form "A is ',(0,n.jsx)(t.strong,{children:(0,n.jsx)(t.em,{children:"greater than"})}),' B," the ',(0,n.jsx)(t.strong,{children:"test statistic"})," should measure ",(0,n.jsx)(t.strong,{children:"signed difference"})," rather than absolute difference."]}),"\n",(0,n.jsxs)(t.p,{children:[(0,n.jsxs)(t.span,{className:"katex",children:[(0,n.jsx)(t.span,{className:"katex-mathml",children:(0,n.jsx)(t.math,{xmlns:"http://www.w3.org/1998/Math/MathML",children:(0,n.jsxs)(t.semantics,{children:[(0,n.jsx)(t.mrow,{children:(0,n.jsx)(t.mo,{children:"\u2234"})}),(0,n.jsx)(t.annotation,{encoding:"application/x-tex",children:"\\therefore"})]})})}),(0,n.jsx)(t.span,{className:"katex-html","aria-hidden":"true",children:(0,n.jsxs)(t.span,{className:"base",children:[(0,n.jsx)(t.span,{className:"strut",style:{height:"0.6922em"}}),(0,n.jsx)(t.span,{className:"mrel amsrm",children:"\u2234"})]})})]})," We use ",(0,n.jsx)(t.strong,{children:"the difference in proportions"})," of white dogs among dogs and white pets in the overall poplulation as the test statistic."]}),"\n",(0,n.jsx)(t.hr,{}),"\n",(0,n.jsx)(t.h3,{id:"2-calculate-the-overall-proportion",children:"2. Calculate the overall proportion"}),"\n",(0,n.jsx)(t.p,{children:"We first compute the proportion of white pets in the overall population, which will be used for calculating the test statistic."}),"\n",(0,n.jsx)(t.pre,{children:(0,n.jsx)(t.code,{className:"language-python",children:"#Method 1: Obtain a series of boolean values (1s and 0s), and calculate the mean\noverall_prop = (full_pets.get('Color')=='white').mean()\n\n#Method 2: Query the DataFrame and obtain the proportion by using .shape[0]\n#overall_prop = full_pets[full_pets.get('Color')=='white'].shape[0]/full_pets.shape[0]\n\noverall_prop\n"})}),"\n",(0,n.jsx)(t.p,{children:"0.2631578947368421"}),"\n",(0,n.jsx)(t.hr,{}),"\n",(0,n.jsx)(t.h3,{id:"3-create-a-function-to-calculate-test-statistic",children:"3. Create a function to calculate test statistic"}),"\n",(0,n.jsx)(t.p,{children:"Create a function to calculate the test statistic during every trial of our hypothesis test."}),"\n",(0,n.jsx)(t.pre,{children:(0,n.jsx)(t.code,{className:"language-python",children:'def difference_in_proportions(dogs_prop, overall_prop):\n """\n Calculate the difference in proportions of white dogs among dogs and white pets in the overall population.\n ---\n Input:\n dogs_prop: the proportion of white dogs among all dogs.\n overall_prop: the proportion of white pets in the overall population.\n ---\n Output:\n The difference in proportions of white dogs among dogs and white pets in the overall population.\n """\n return dogs_prop - overall_prop\n'})}),"\n",(0,n.jsx)(t.p,{children:(0,n.jsx)(t.em,{children:"Note: Although we can simply do this in the for-loop shown in the next step, we can practice good coding habits by separating our code into readable bits!"})}),"\n",(0,n.jsx)(t.hr,{}),"\n",(0,n.jsx)(t.h3,{id:"4-compute-the-observed-statistic",children:"4. Compute the observed statistic"}),"\n",(0,n.jsx)(t.pre,{children:(0,n.jsx)(t.code,{className:"language-python",children:"# Query the DataFrame to only include dogs\ndogs_df = full_pets[full_pets.get('Species') == 'dog']\n# Compute the observed proportion of white dogs among all dogs\nobs_dogs_prop = (dogs_df.get('Color') == 'white').mean()\n# Calculate the observed statistic\nobserved_stat = difference_in_proportions(obs_dogs_prop, overall_prop)\nobserved_stat\n"})}),"\n",(0,n.jsx)(t.p,{children:"0.18128654970760233"}),"\n",(0,n.jsx)(t.hr,{}),"\n",(0,n.jsx)(t.h3,{id:"5-simulate-the-hypothesis-test-under-the-null-hypothesis",children:"5. Simulate the hypothesis test under the null hypothesis"}),"\n",(0,n.jsx)(t.pre,{children:(0,n.jsx)(t.code,{className:"language-python",children:'n = 500 # Number of simulations.\ntest_statistics = np.array([]) # Array to keep track of the test statistic for each iteration.\nfor i in np.arange(n): # Run the simulation `n` number of times\n # 1. Simulate the dogs distribution\n \n # Calculte the smaple size (number of dogs)\n sample_size = dogs_df.shape[0]\n \n # Under the null hypothesis, proportion of "white" dogs among dogs is equal to the proportion of white pets among the overall population\n model_proportions = np.array([obs_dogs_prop, 1-obs_dogs_prop]) \n \n # Calculate the the proportion of white dogs among all dogs.\n simulation_proportion = np.random.multinomial(sample_size, model_proportions)[0] / sample_size\n \n # 2. Compute the test statistic\n test_stat = difference_in_proportions(simulation_proportion, overall_prop)\n\n # 3. Save the result\n test_statistics = np.append(test_statistics, test_stat)\n'})}),"\n",(0,n.jsxs)(t.p,{children:["This code will run the permutation test 500 times, but a different reasonable number can be used instead. It is ",(0,n.jsx)(t.strong,{children:"crucial"})," to keep track of the test statistic each time our for-loop runs so that the number of simulated values can be stored."]}),"\n",(0,n.jsx)(t.hr,{}),"\n",(0,n.jsx)(t.h3,{id:"6-conclusion",children:"6. Conclusion"}),"\n",(0,n.jsx)(t.pre,{children:(0,n.jsx)(t.code,{className:"language-python",children:'p_value = np.count_nonzero(test_statistics >= observed_stat) / n\n\nprint("The observed value of the test statistic is:", observed_stat)\nprint("The p-value is:", p_value)\n'})}),"\n",(0,n.jsxs)(t.p,{children:[(0,n.jsx)(t.strong,{children:"The observed value of the test statistic is:"})," 0.18128654970760233 ",(0,n.jsx)("br",{}),"\n",(0,n.jsx)(t.strong,{children:"The p-value is:"})," 0.616"]}),"\n",(0,n.jsx)(t.p,{children:"Using a significance level of 0.05:"}),"\n",(0,n.jsx)(t.admonition,{title:"Conclusion",type:"info",children:(0,n.jsxs)(t.ul,{children:["\n",(0,n.jsx)(t.li,{children:"Under the null hypothesis, there is a sufficiently large probability of seeing a difference greater than the observed value. The data are consistent with the null hypothesis."}),"\n",(0,n.jsxs)(t.li,{children:["Since our p-value is greater than 0.05, we ",(0,n.jsx)(t.strong,{children:"fail to reject"})," the null hypothesis."]}),"\n"]})}),"\n",(0,n.jsx)(t.hr,{}),"\n",(0,n.jsx)(t.h3,{id:"7-extra",children:"7. Extra"}),"\n",(0,n.jsx)(t.p,{children:"Let's see how our observed statistic compares to the overall simulated values!"}),"\n",(0,n.jsx)(t.pre,{children:(0,n.jsx)(t.code,{className:"language-python",children:"# Create the histogram.\nbpd.DataFrame().assign(test_statistics=test_statistics).plot(kind='hist', bins= 10, density=True, ec='w')\n# Don't worry about these lines - you won't need to know it for this course!\nplt.axvline(x=observed_stat, c='black', linewidth=4);\nyticks = plt.gca().get_yticks()\nplt.yticks(yticks, np.round(yticks * 0.1, 2))\nplt.show()\n"})}),"\n",(0,n.jsx)(t.p,{children:(0,n.jsx)(t.img,{alt:"Distribution",src:s(2527).A+"",width:"640",height:"480"})}),"\n",(0,n.jsxs)(t.p,{children:["From this graph, we can see that more than half of the data are to the ",(0,n.jsx)(t.strong,{children:"right"})," of the black vertical line (our observed test statistic), meaning we have a relatively high p-value!"]}),"\n",(0,n.jsx)(t.hr,{}),"\n",(0,n.jsx)(t.h2,{id:"code-example-2-tvd",children:"Code Example 2 (TVD)"}),"\n",(0,n.jsx)(t.h3,{id:"1-state-the-questionhypothesis-1",children:"1. State the question/hypothesis"}),"\n",(0,n.jsx)(t.p,{children:"We found that the color distribution of dogs seems different from that of all pets."}),"\n",(0,n.jsx)(o.A,{data:'{"columns":["Pets_Dist","Dogs_Dist"],"index":["black","golden","white"],"data":[[0.53,0.44],[0.21,0.11],[0.26,0.44]]}'}),"\n",(0,n.jsx)(t.p,{children:"To see whether this difference is due to random chance, we will test the following pair of hypotheses at the standard p = 0.05 significance level."}),"\n",(0,n.jsx)(t.admonition,{title:"Hypotheses",type:"info",children:(0,n.jsxs)(t.ul,{children:["\n",(0,n.jsxs)(t.li,{children:[(0,n.jsx)(t.strong,{children:"Null Hypothesis:"})," The color distribution of dogs is the ",(0,n.jsx)(t.strong,{children:"same as"})," the color distribution of pets."]}),"\n",(0,n.jsxs)(t.li,{children:[(0,n.jsx)(t.strong,{children:"Alternative Hypothesis:"})," The color distribution of dogs is ",(0,n.jsx)(t.strong,{children:"different from"})," the color distribution of pets."]}),"\n"]})}),"\n",(0,n.jsxs)(t.p,{children:["Since we are comparing two ",(0,n.jsx)(t.strong,{children:"categorical"})," distributions, we use Total Variation Distance (TVD) between the two distributions as our ",(0,n.jsx)(t.strong,{children:"test statistic"}),"."]}),"\n",(0,n.jsx)(t.hr,{})]})}function p(e={}){const{wrapper:t}={...(0,i.R)(),...e.components};return t?(0,n.jsx)(t,{...e,children:(0,n.jsx)(d,{...e})}):d(e)}},8597:(e,t,s)=>{s.d(t,{A:()=>i});s(6540);var n=s(4848);const i=e=>{let{data:t}=e,s=[],i=[],o="",r=[];if(t){const e=JSON.parse(t);s=e.columns||[],i=e.data||[],o=e.indexName||"Index",r=e.index||[]}return(0,n.jsx)("div",{className:"dataframe-container",children:(0,n.jsxs)("table",{className:"dataframe-table",children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{children:o}),s.map(((e,t)=>(0,n.jsx)("th",{children:e},t)))]})}),(0,n.jsx)("tbody",{children:i.map(((e,t)=>(0,n.jsxs)("tr",{children:[(0,n.jsx)("td",{className:"index-value",children:r[t]}),e.map(((e,t)=>{return(0,n.jsx)("td",{children:(s=e,"boolean"==typeof s?s.toString().charAt(0).toUpperCase()+s.toString().slice(1):s)},t);var s}))]},t)))})]})})}},5158:(e,t,s)=>{s.d(t,{A:()=>o});var n=s(6540),i=s(4848);const o=function(e){let{src:t,sourceLink:s,aspectRatio:o=16/9}=e;const[r,a]=(0,n.useState)(0),[l,h]=(0,n.useState)(0),c=(0,n.useRef)(null);return(0,n.useEffect)((()=>{const e=()=>{if(c.current){const e=c.current.offsetWidth;h(e/o)}};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)}),[o]),(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("div",{ref:c,style:{width:"100%",position:"relative",maxWidth:"100%",backgroundColor:"white"},children:(0,i.jsx)("iframe",{src:t,style:{width:"100%",height:`${l}px`,border:"0",allowFullScreen:!0}},r)}),(0,i.jsx)("div",{style:{display:"flex",justifyContent:"center",margin:"20px 0"},children:(0,i.jsx)("a",{href:s,target:"_blank",rel:"noopener noreferrer",children:"(Source)"})}),(0,i.jsx)("div",{style:{display:"flex",justifyContent:"center",margin:"10px 0"},children:(0,i.jsx)("button",{onClick:()=>{a((e=>e+1))},style:{backgroundColor:"#4CAF50",color:"white",padding:"10px 20px",border:"none",borderRadius:"5px",cursor:"pointer",outline:"none",fontSize:"16px",fontWeight:"bold",boxShadow:"0 4px 8px rgba(0,0,0,0.1)",transition:"background-color 0.3s"},onMouseOver:e=>e.currentTarget.style.backgroundColor="#45a049",onMouseOut:e=>e.currentTarget.style.backgroundColor="#4CAF50",children:"Restart Diagram"})})]})}},2527:(e,t,s)=>{s.d(t,{A:()=>n});const n=s.p+"assets/images/hypothesis-test-776f8723e19318f4f91020489482dcf5.png"},8453:(e,t,s)=>{s.d(t,{R:()=>r,x:()=>a});var n=s(6540);const i={},o=n.createContext(i);function r(e){const t=n.useContext(o);return n.useMemo((function(){return"function"==typeof e?e(t):{...t,...e}}),[t,e])}function a(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:r(e.components),n.createElement(o.Provider,{value:t},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/runtime~main.dda7f4e2.js b/assets/js/runtime~main.d66ee0d1.js similarity index 97% rename from assets/js/runtime~main.dda7f4e2.js rename to assets/js/runtime~main.d66ee0d1.js index c6f65439..6bf1cab1 100644 --- a/assets/js/runtime~main.dda7f4e2.js +++ b/assets/js/runtime~main.d66ee0d1.js @@ -1 +1 @@ -(()=>{"use strict";var e,a,f,c,d,b={},r={};function t(e){var a=r[e];if(void 0!==a)return a.exports;var f=r[e]={id:e,loaded:!1,exports:{}};return b[e].call(f.exports,f,f.exports,t),f.loaded=!0,f.exports}t.m=b,t.c=r,e=[],t.O=(a,f,c,d)=>{if(!f){var b=1/0;for(i=0;i=d)&&Object.keys(t.O).every((e=>t.O[e](f[o])))?f.splice(o--,1):(r=!1,d0&&e[i-1][2]>d;i--)e[i]=e[i-1];e[i]=[f,c,d]},t.n=e=>{var a=e&&e.__esModule?()=>e.default:()=>e;return t.d(a,{a:a}),a},f=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,t.t=function(e,c){if(1&c&&(e=this(e)),8&c)return e;if("object"==typeof e&&e){if(4&c&&e.__esModule)return e;if(16&c&&"function"==typeof e.then)return e}var d=Object.create(null);t.r(d);var b={};a=a||[null,f({}),f([]),f(f)];for(var r=2&c&&e;"object"==typeof r&&!~a.indexOf(r);r=f(r))Object.getOwnPropertyNames(r).forEach((a=>b[a]=()=>e[a]));return b.default=()=>e,t.d(d,b),d},t.d=(e,a)=>{for(var f in a)t.o(a,f)&&!t.o(e,f)&&Object.defineProperty(e,f,{enumerable:!0,get:a[f]})},t.f={},t.e=e=>Promise.all(Object.keys(t.f).reduce(((a,f)=>(t.f[f](e,a),a)),[])),t.u=e=>"assets/js/"+({28:"f095f4cd",94:"81322b72",186:"2869c049",614:"f2b0891e",675:"82ff9878",719:"9ac7dbcc",972:"f03ae67e",1316:"62552850",1607:"faf9f7da",1614:"e10a9913",1746:"a278cdf6",1779:"9a265863",1870:"ee019b1d",1903:"9e7aae35",1944:"b0c30e46",1972:"73664a40",1979:"b69909d7",2087:"f0fd5c00",2105:"dd3b6db1",2138:"1a4e3797",2284:"6e05dac9",2302:"499d47b2",2334:"65beeb93",2441:"9e1896f0",2456:"36d89dbe",2491:"acb40918",2634:"c4f5d8e4",2646:"0c6397b1",2711:"9e4087bc",2720:"10f7d562",2808:"f0994678",2917:"dfefbedb",3237:"2be9118b",3249:"ccc49370",3279:"1fc0ff79",3342:"f9684ee2",3343:"f3b65525",3362:"f39390d7",3404:"a5070059",3484:"c94468d5",3508:"202baea0",3555:"d3ef55ca",3637:"f4f34a3a",3694:"8717b14a",3717:"099c0b96",3782:"6e7a31fd",3870:"37002ad4",3985:"1cf20db4",4266:"8ded1294",4279:"df203c0f",4284:"acecf23e",4469:"6a26c916",4551:"907d0c45",4567:"655190df",4594:"62efbc4a",4638:"9746c0ef",4787:"3720c009",4812:"739bf370",4813:"6875c492",4833:"d4f68316",4929:"b78139e1",4932:"6b67e948",5007:"e06ba05c",5119:"d28047a2",5125:"10297ef4",5151:"55960ee5",5296:"14acb028",5387:"a934ee8a",5391:"cd451366",5427:"956f17b0",5443:"add9b02f",5480:"09399a2b",5521:"38b2e376",5557:"d9f32620",5579:"46ccc97a",5589:"ea885f1b",5622:"5d6a2894",5743:"231a3aa4",5745:"8d40581b",5980:"6e2ca103",6061:"1f391b9e",6077:"ffbcff43",6090:"3f791b14",6137:"61546123",6142:"60c4aef6",6264:"187e374f",6280:"5ddb68ca",6363:"2141c98b",6690:"920988e2",6730:"b7ff327f",6747:"f4434bba",6787:"eb170cfd",6925:"ecad1ce6",6969:"14eb3368",7069:"2efbf384",7098:"a7bd4aaa",7174:"a4805c9a",7214:"dcbe5aac",7233:"f4c1c84a",7326:"03f8d3d3",7472:"814f3328",7489:"fe41946a",7643:"a6aa9e1f",7661:"26533384",7680:"cdae2dcc",7795:"f3976560",7889:"a16987a3",8065:"80770d40",8104:"d3196d0d",8209:"01a85c17",8241:"de98ccb0",8401:"17896441",8405:"6d7cf8c9",8559:"3349ad3a",8581:"935f2afb",8609:"925b3f96",8675:"809bd41b",8737:"7661071f",8857:"0708938a",9048:"a94703ab",9316:"3b87ebee",9325:"59362658",9328:"e273c56f",9448:"1774e1e3",9572:"8c496670",9595:"fb17983f",9600:"eaaf288f",9647:"5e95c892",9699:"f9ea3bc3",9797:"85bbc213",9894:"9f1843d8",9933:"9c6685b1",9938:"3eb51302"}[e]||e)+"."+{28:"cea56b28",94:"90d5758b",186:"7590b2dd",614:"d7eac5db",675:"9143662a",719:"77c0c128",972:"fff9d33b",1316:"611cdd05",1607:"a670a186",1614:"b87367c0",1746:"6d5ef8b3",1779:"faf30e2f",1870:"83c014e4",1903:"af9e1878",1944:"494989bc",1972:"6864c464",1979:"cf14dce4",2087:"4df4c5a5",2105:"3ea3e8be",2138:"aadba9b7",2237:"29af0789",2284:"5de02c24",2302:"394129d8",2334:"92288123",2441:"53464e90",2456:"abf69e17",2491:"20b35a67",2634:"f7cd0456",2646:"4c026ca7",2711:"8dd0f02f",2720:"9b0bb4fc",2808:"04e51180",2917:"f0f27122",3237:"1e62f3f0",3242:"bc6cfa22",3249:"ede845d6",3279:"66617d79",3342:"94223911",3343:"792c19b9",3362:"8c037730",3404:"d420f5a2",3484:"c6edfbc0",3508:"908c6f0c",3555:"2308a0a5",3637:"b17e442f",3694:"5454028b",3717:"cd0ce1aa",3782:"37c8f8e9",3808:"8a31a624",3870:"05ddd35d",3985:"a1948cc0",4266:"513e7c38",4279:"9bb05a46",4284:"6510b036",4469:"af28a919",4551:"7e422b8d",4567:"23a73ffd",4594:"00648062",4638:"2880f7ec",4787:"9b65805f",4812:"a6284299",4813:"170acbab",4833:"a09dc9fc",4929:"88fdbdc8",4932:"0e1c3290",5007:"2fc679a2",5049:"fc44c2c6",5119:"42cfdd1b",5125:"8f93c5d4",5151:"5f7b8339",5296:"d858fe86",5387:"7e4093f8",5391:"27038027",5427:"95f66799",5443:"bf2acfd8",5480:"c91de645",5521:"3d83e140",5557:"9fd27735",5579:"c2d0e88e",5589:"9a7123df",5622:"ac62096c",5743:"bb1b0a14",5745:"0f3d989b",5980:"7621ee3b",6061:"0fbbc924",6077:"e95668eb",6090:"fee676c1",6137:"d6ca9f5a",6142:"bacecd71",6264:"00e1cc00",6280:"036894d0",6363:"8ceae88c",6690:"1a73d040",6730:"d6f9457e",6747:"0479fbaa",6787:"253b7f3e",6925:"45e66795",6969:"66f25eb3",7069:"0f6f23fb",7098:"7f57ba47",7174:"53481746",7214:"70a12792",7233:"0250807e",7326:"65063e2e",7472:"2a71da77",7489:"a8daece4",7643:"e66b5d79",7661:"ba125169",7680:"872a7974",7795:"e6a51183",7889:"423d1bcd",8065:"88d53b0f",8104:"987cf125",8209:"9fbc266e",8241:"92417364",8401:"e72d0c45",8405:"81b437c0",8559:"33a087db",8581:"2ebb51c4",8609:"cba4ee15",8675:"0c13f0ab",8737:"8c73ff37",8857:"fbfbdee8",8913:"a03b371c",9048:"be35ee30",9316:"65aa3284",9325:"777bc4c6",9328:"f95f7890",9448:"31a80d1b",9462:"c36291a8",9572:"3ecad696",9595:"d5f88d2e",9600:"10ee7159",9647:"c487ac59",9699:"f12abbc7",9797:"59604264",9894:"e87af32a",9933:"77d25a1f",9938:"ade32d2c"}[e]+".js",t.miniCssF=e=>{},t.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),t.o=(e,a)=>Object.prototype.hasOwnProperty.call(e,a),c={},d="bpd-reference:",t.l=(e,a,f,b)=>{if(c[e])c[e].push(a);else{var r,o;if(void 0!==f)for(var n=document.getElementsByTagName("script"),i=0;i{r.onerror=r.onload=null,clearTimeout(s);var d=c[e];if(delete c[e],r.parentNode&&r.parentNode.removeChild(r),d&&d.forEach((e=>e(f))),a)return a(f)},s=setTimeout(l.bind(null,void 0,{type:"timeout",target:r}),12e4);r.onerror=l.bind(null,r.onerror),r.onload=l.bind(null,r.onload),o&&document.head.appendChild(r)}},t.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.p="/bpd-reference/",t.gca=function(e){return e={17896441:"8401",26533384:"7661",59362658:"9325",61546123:"6137",62552850:"1316",f095f4cd:"28","81322b72":"94","2869c049":"186",f2b0891e:"614","82ff9878":"675","9ac7dbcc":"719",f03ae67e:"972",faf9f7da:"1607",e10a9913:"1614",a278cdf6:"1746","9a265863":"1779",ee019b1d:"1870","9e7aae35":"1903",b0c30e46:"1944","73664a40":"1972",b69909d7:"1979",f0fd5c00:"2087",dd3b6db1:"2105","1a4e3797":"2138","6e05dac9":"2284","499d47b2":"2302","65beeb93":"2334","9e1896f0":"2441","36d89dbe":"2456",acb40918:"2491",c4f5d8e4:"2634","0c6397b1":"2646","9e4087bc":"2711","10f7d562":"2720",f0994678:"2808",dfefbedb:"2917","2be9118b":"3237",ccc49370:"3249","1fc0ff79":"3279",f9684ee2:"3342",f3b65525:"3343",f39390d7:"3362",a5070059:"3404",c94468d5:"3484","202baea0":"3508",d3ef55ca:"3555",f4f34a3a:"3637","8717b14a":"3694","099c0b96":"3717","6e7a31fd":"3782","37002ad4":"3870","1cf20db4":"3985","8ded1294":"4266",df203c0f:"4279",acecf23e:"4284","6a26c916":"4469","907d0c45":"4551","655190df":"4567","62efbc4a":"4594","9746c0ef":"4638","3720c009":"4787","739bf370":"4812","6875c492":"4813",d4f68316:"4833",b78139e1:"4929","6b67e948":"4932",e06ba05c:"5007",d28047a2:"5119","10297ef4":"5125","55960ee5":"5151","14acb028":"5296",a934ee8a:"5387",cd451366:"5391","956f17b0":"5427",add9b02f:"5443","09399a2b":"5480","38b2e376":"5521",d9f32620:"5557","46ccc97a":"5579",ea885f1b:"5589","5d6a2894":"5622","231a3aa4":"5743","8d40581b":"5745","6e2ca103":"5980","1f391b9e":"6061",ffbcff43:"6077","3f791b14":"6090","60c4aef6":"6142","187e374f":"6264","5ddb68ca":"6280","2141c98b":"6363","920988e2":"6690",b7ff327f:"6730",f4434bba:"6747",eb170cfd:"6787",ecad1ce6:"6925","14eb3368":"6969","2efbf384":"7069",a7bd4aaa:"7098",a4805c9a:"7174",dcbe5aac:"7214",f4c1c84a:"7233","03f8d3d3":"7326","814f3328":"7472",fe41946a:"7489",a6aa9e1f:"7643",cdae2dcc:"7680",f3976560:"7795",a16987a3:"7889","80770d40":"8065",d3196d0d:"8104","01a85c17":"8209",de98ccb0:"8241","6d7cf8c9":"8405","3349ad3a":"8559","935f2afb":"8581","925b3f96":"8609","809bd41b":"8675","7661071f":"8737","0708938a":"8857",a94703ab:"9048","3b87ebee":"9316",e273c56f:"9328","1774e1e3":"9448","8c496670":"9572",fb17983f:"9595",eaaf288f:"9600","5e95c892":"9647",f9ea3bc3:"9699","85bbc213":"9797","9f1843d8":"9894","9c6685b1":"9933","3eb51302":"9938"}[e]||e,t.p+t.u(e)},(()=>{var e={5354:0,1869:0};t.f.j=(a,f)=>{var c=t.o(e,a)?e[a]:void 0;if(0!==c)if(c)f.push(c[2]);else if(/^(1869|5354)$/.test(a))e[a]=0;else{var d=new Promise(((f,d)=>c=e[a]=[f,d]));f.push(c[2]=d);var b=t.p+t.u(a),r=new Error;t.l(b,(f=>{if(t.o(e,a)&&(0!==(c=e[a])&&(e[a]=void 0),c)){var d=f&&("load"===f.type?"missing":f.type),b=f&&f.target&&f.target.src;r.message="Loading chunk "+a+" failed.\n("+d+": "+b+")",r.name="ChunkLoadError",r.type=d,r.request=b,c[1](r)}}),"chunk-"+a,a)}},t.O.j=a=>0===e[a];var a=(a,f)=>{var c,d,b=f[0],r=f[1],o=f[2],n=0;if(b.some((a=>0!==e[a]))){for(c in r)t.o(r,c)&&(t.m[c]=r[c]);if(o)var i=o(t)}for(a&&a(f);n{"use strict";var e,a,f,c,d,b={},r={};function t(e){var a=r[e];if(void 0!==a)return a.exports;var f=r[e]={id:e,loaded:!1,exports:{}};return b[e].call(f.exports,f,f.exports,t),f.loaded=!0,f.exports}t.m=b,t.c=r,e=[],t.O=(a,f,c,d)=>{if(!f){var b=1/0;for(i=0;i=d)&&Object.keys(t.O).every((e=>t.O[e](f[o])))?f.splice(o--,1):(r=!1,d0&&e[i-1][2]>d;i--)e[i]=e[i-1];e[i]=[f,c,d]},t.n=e=>{var a=e&&e.__esModule?()=>e.default:()=>e;return t.d(a,{a:a}),a},f=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,t.t=function(e,c){if(1&c&&(e=this(e)),8&c)return e;if("object"==typeof e&&e){if(4&c&&e.__esModule)return e;if(16&c&&"function"==typeof e.then)return e}var d=Object.create(null);t.r(d);var b={};a=a||[null,f({}),f([]),f(f)];for(var r=2&c&&e;"object"==typeof r&&!~a.indexOf(r);r=f(r))Object.getOwnPropertyNames(r).forEach((a=>b[a]=()=>e[a]));return b.default=()=>e,t.d(d,b),d},t.d=(e,a)=>{for(var f in a)t.o(a,f)&&!t.o(e,f)&&Object.defineProperty(e,f,{enumerable:!0,get:a[f]})},t.f={},t.e=e=>Promise.all(Object.keys(t.f).reduce(((a,f)=>(t.f[f](e,a),a)),[])),t.u=e=>"assets/js/"+({28:"f095f4cd",94:"81322b72",186:"2869c049",614:"f2b0891e",675:"82ff9878",719:"9ac7dbcc",972:"f03ae67e",1316:"62552850",1607:"faf9f7da",1614:"e10a9913",1746:"a278cdf6",1779:"9a265863",1870:"ee019b1d",1903:"9e7aae35",1944:"b0c30e46",1972:"73664a40",1979:"b69909d7",2087:"f0fd5c00",2105:"dd3b6db1",2138:"1a4e3797",2284:"6e05dac9",2302:"499d47b2",2334:"65beeb93",2441:"9e1896f0",2456:"36d89dbe",2491:"acb40918",2634:"c4f5d8e4",2646:"0c6397b1",2711:"9e4087bc",2720:"10f7d562",2808:"f0994678",2917:"dfefbedb",3237:"2be9118b",3249:"ccc49370",3279:"1fc0ff79",3342:"f9684ee2",3343:"f3b65525",3362:"f39390d7",3404:"a5070059",3484:"c94468d5",3508:"202baea0",3555:"d3ef55ca",3637:"f4f34a3a",3694:"8717b14a",3717:"099c0b96",3782:"6e7a31fd",3870:"37002ad4",3985:"1cf20db4",4266:"8ded1294",4279:"df203c0f",4284:"acecf23e",4469:"6a26c916",4551:"907d0c45",4567:"655190df",4594:"62efbc4a",4638:"9746c0ef",4787:"3720c009",4812:"739bf370",4813:"6875c492",4833:"d4f68316",4929:"b78139e1",4932:"6b67e948",5007:"e06ba05c",5119:"d28047a2",5125:"10297ef4",5151:"55960ee5",5296:"14acb028",5387:"a934ee8a",5391:"cd451366",5427:"956f17b0",5443:"add9b02f",5480:"09399a2b",5521:"38b2e376",5557:"d9f32620",5579:"46ccc97a",5589:"ea885f1b",5622:"5d6a2894",5743:"231a3aa4",5745:"8d40581b",5980:"6e2ca103",6061:"1f391b9e",6077:"ffbcff43",6090:"3f791b14",6137:"61546123",6142:"60c4aef6",6264:"187e374f",6280:"5ddb68ca",6363:"2141c98b",6690:"920988e2",6730:"b7ff327f",6747:"f4434bba",6787:"eb170cfd",6925:"ecad1ce6",6969:"14eb3368",7069:"2efbf384",7098:"a7bd4aaa",7174:"a4805c9a",7214:"dcbe5aac",7233:"f4c1c84a",7326:"03f8d3d3",7472:"814f3328",7489:"fe41946a",7643:"a6aa9e1f",7661:"26533384",7680:"cdae2dcc",7795:"f3976560",7889:"a16987a3",8065:"80770d40",8104:"d3196d0d",8209:"01a85c17",8241:"de98ccb0",8401:"17896441",8405:"6d7cf8c9",8559:"3349ad3a",8581:"935f2afb",8609:"925b3f96",8675:"809bd41b",8737:"7661071f",8857:"0708938a",9048:"a94703ab",9316:"3b87ebee",9325:"59362658",9328:"e273c56f",9448:"1774e1e3",9572:"8c496670",9595:"fb17983f",9600:"eaaf288f",9647:"5e95c892",9699:"f9ea3bc3",9797:"85bbc213",9894:"9f1843d8",9933:"9c6685b1",9938:"3eb51302"}[e]||e)+"."+{28:"cea56b28",94:"90d5758b",186:"7590b2dd",614:"d7eac5db",675:"9143662a",719:"77c0c128",972:"4876c58e",1316:"611cdd05",1607:"a670a186",1614:"b87367c0",1746:"6d5ef8b3",1779:"faf30e2f",1870:"83c014e4",1903:"af9e1878",1944:"494989bc",1972:"6864c464",1979:"cf14dce4",2087:"4df4c5a5",2105:"3ea3e8be",2138:"aadba9b7",2237:"29af0789",2284:"5de02c24",2302:"394129d8",2334:"92288123",2441:"53464e90",2456:"abf69e17",2491:"20b35a67",2634:"f7cd0456",2646:"4c026ca7",2711:"8dd0f02f",2720:"9b0bb4fc",2808:"04e51180",2917:"f0f27122",3237:"1e62f3f0",3242:"bc6cfa22",3249:"ede845d6",3279:"66617d79",3342:"94223911",3343:"792c19b9",3362:"8c037730",3404:"d420f5a2",3484:"c6edfbc0",3508:"908c6f0c",3555:"2308a0a5",3637:"b17e442f",3694:"5454028b",3717:"cd0ce1aa",3782:"37c8f8e9",3808:"8a31a624",3870:"05ddd35d",3985:"a1948cc0",4266:"513e7c38",4279:"9bb05a46",4284:"6510b036",4469:"af28a919",4551:"7e422b8d",4567:"23a73ffd",4594:"00648062",4638:"2880f7ec",4787:"9b65805f",4812:"a6284299",4813:"170acbab",4833:"39fbf26a",4929:"88fdbdc8",4932:"0e1c3290",5007:"2fc679a2",5049:"fc44c2c6",5119:"42cfdd1b",5125:"8f93c5d4",5151:"5f7b8339",5296:"d858fe86",5387:"7e4093f8",5391:"27038027",5427:"95f66799",5443:"bf2acfd8",5480:"c91de645",5521:"3d83e140",5557:"9fd27735",5579:"c2d0e88e",5589:"9a7123df",5622:"ac62096c",5743:"bb1b0a14",5745:"0f3d989b",5980:"7621ee3b",6061:"0fbbc924",6077:"e95668eb",6090:"fee676c1",6137:"d6ca9f5a",6142:"04bec992",6264:"00e1cc00",6280:"036894d0",6363:"8ceae88c",6690:"1a73d040",6730:"d6f9457e",6747:"0479fbaa",6787:"253b7f3e",6925:"45e66795",6969:"66f25eb3",7069:"0f6f23fb",7098:"7f57ba47",7174:"53481746",7214:"70a12792",7233:"0250807e",7326:"65063e2e",7472:"2a71da77",7489:"a8daece4",7643:"e66b5d79",7661:"ba125169",7680:"872a7974",7795:"e6a51183",7889:"423d1bcd",8065:"88d53b0f",8104:"987cf125",8209:"9fbc266e",8241:"92417364",8401:"e72d0c45",8405:"81b437c0",8559:"33a087db",8581:"2ebb51c4",8609:"cba4ee15",8675:"0c13f0ab",8737:"8c73ff37",8857:"fbfbdee8",8913:"a03b371c",9048:"be35ee30",9316:"65aa3284",9325:"777bc4c6",9328:"f95f7890",9448:"31a80d1b",9462:"c36291a8",9572:"3ecad696",9595:"d5f88d2e",9600:"10ee7159",9647:"c487ac59",9699:"f12abbc7",9797:"59604264",9894:"98b107ad",9933:"77d25a1f",9938:"ade32d2c"}[e]+".js",t.miniCssF=e=>{},t.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),t.o=(e,a)=>Object.prototype.hasOwnProperty.call(e,a),c={},d="bpd-reference:",t.l=(e,a,f,b)=>{if(c[e])c[e].push(a);else{var r,o;if(void 0!==f)for(var n=document.getElementsByTagName("script"),i=0;i{r.onerror=r.onload=null,clearTimeout(s);var d=c[e];if(delete c[e],r.parentNode&&r.parentNode.removeChild(r),d&&d.forEach((e=>e(f))),a)return a(f)},s=setTimeout(l.bind(null,void 0,{type:"timeout",target:r}),12e4);r.onerror=l.bind(null,r.onerror),r.onload=l.bind(null,r.onload),o&&document.head.appendChild(r)}},t.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.p="/bpd-reference/",t.gca=function(e){return e={17896441:"8401",26533384:"7661",59362658:"9325",61546123:"6137",62552850:"1316",f095f4cd:"28","81322b72":"94","2869c049":"186",f2b0891e:"614","82ff9878":"675","9ac7dbcc":"719",f03ae67e:"972",faf9f7da:"1607",e10a9913:"1614",a278cdf6:"1746","9a265863":"1779",ee019b1d:"1870","9e7aae35":"1903",b0c30e46:"1944","73664a40":"1972",b69909d7:"1979",f0fd5c00:"2087",dd3b6db1:"2105","1a4e3797":"2138","6e05dac9":"2284","499d47b2":"2302","65beeb93":"2334","9e1896f0":"2441","36d89dbe":"2456",acb40918:"2491",c4f5d8e4:"2634","0c6397b1":"2646","9e4087bc":"2711","10f7d562":"2720",f0994678:"2808",dfefbedb:"2917","2be9118b":"3237",ccc49370:"3249","1fc0ff79":"3279",f9684ee2:"3342",f3b65525:"3343",f39390d7:"3362",a5070059:"3404",c94468d5:"3484","202baea0":"3508",d3ef55ca:"3555",f4f34a3a:"3637","8717b14a":"3694","099c0b96":"3717","6e7a31fd":"3782","37002ad4":"3870","1cf20db4":"3985","8ded1294":"4266",df203c0f:"4279",acecf23e:"4284","6a26c916":"4469","907d0c45":"4551","655190df":"4567","62efbc4a":"4594","9746c0ef":"4638","3720c009":"4787","739bf370":"4812","6875c492":"4813",d4f68316:"4833",b78139e1:"4929","6b67e948":"4932",e06ba05c:"5007",d28047a2:"5119","10297ef4":"5125","55960ee5":"5151","14acb028":"5296",a934ee8a:"5387",cd451366:"5391","956f17b0":"5427",add9b02f:"5443","09399a2b":"5480","38b2e376":"5521",d9f32620:"5557","46ccc97a":"5579",ea885f1b:"5589","5d6a2894":"5622","231a3aa4":"5743","8d40581b":"5745","6e2ca103":"5980","1f391b9e":"6061",ffbcff43:"6077","3f791b14":"6090","60c4aef6":"6142","187e374f":"6264","5ddb68ca":"6280","2141c98b":"6363","920988e2":"6690",b7ff327f:"6730",f4434bba:"6747",eb170cfd:"6787",ecad1ce6:"6925","14eb3368":"6969","2efbf384":"7069",a7bd4aaa:"7098",a4805c9a:"7174",dcbe5aac:"7214",f4c1c84a:"7233","03f8d3d3":"7326","814f3328":"7472",fe41946a:"7489",a6aa9e1f:"7643",cdae2dcc:"7680",f3976560:"7795",a16987a3:"7889","80770d40":"8065",d3196d0d:"8104","01a85c17":"8209",de98ccb0:"8241","6d7cf8c9":"8405","3349ad3a":"8559","935f2afb":"8581","925b3f96":"8609","809bd41b":"8675","7661071f":"8737","0708938a":"8857",a94703ab:"9048","3b87ebee":"9316",e273c56f:"9328","1774e1e3":"9448","8c496670":"9572",fb17983f:"9595",eaaf288f:"9600","5e95c892":"9647",f9ea3bc3:"9699","85bbc213":"9797","9f1843d8":"9894","9c6685b1":"9933","3eb51302":"9938"}[e]||e,t.p+t.u(e)},(()=>{var e={5354:0,1869:0};t.f.j=(a,f)=>{var c=t.o(e,a)?e[a]:void 0;if(0!==c)if(c)f.push(c[2]);else if(/^(1869|5354)$/.test(a))e[a]=0;else{var d=new Promise(((f,d)=>c=e[a]=[f,d]));f.push(c[2]=d);var b=t.p+t.u(a),r=new Error;t.l(b,(f=>{if(t.o(e,a)&&(0!==(c=e[a])&&(e[a]=void 0),c)){var d=f&&("load"===f.type?"missing":f.type),b=f&&f.target&&f.target.src;r.message="Loading chunk "+a+" failed.\n("+d+": "+b+")",r.name="ChunkLoadError",r.type=d,r.request=b,c[1](r)}}),"chunk-"+a,a)}},t.O.j=a=>0===e[a];var a=(a,f)=>{var c,d,b=f[0],r=f[1],o=f[2],n=0;if(b.some((a=>0!==e[a]))){for(c in r)t.o(r,c)&&(t.m[c]=r[c]);if(o)var i=o(t)}for(a&&a(f);n

Hypothesis Test vs. Permutation Test

Difference

-

Hypothesis Testing

+

(Standard) Hypothesis Test

  • A population distribution.
  • One observed sample.
  • Answers questions in the form: Does this sample look like it was drawn from the population?
-

Permutation Testing

+

Permutation Test

  • No information about any population distributions.
  • Two observed samples.
  • diff --git a/docs/statistical-inference/hypothesis_test/index.html b/docs/statistical-inference/hypothesis_test/index.html index 3177fc3e..e96fa87b 100644 --- a/docs/statistical-inference/hypothesis_test/index.html +++ b/docs/statistical-inference/hypothesis_test/index.html @@ -11,11 +11,12 @@ - +

    Hypothesis Test

    Concept

    +
    Note 🌟

    This page refers to the standard hypothesis test.

    Key Idea

    We use a hypothesis test to test whether a sample was drawn from a population.

    Terminology

    Hypothesis Test: A process that test whether a sample was drawn from a population, given a population distribution and a sample.

    To conduct a hypothesis test:

    1. Simulate the experiment many times under the assumption that the null hypothesis is true.
    2. @@ -47,8 +48,8 @@

      5. Simulate the hypothesis test under the null hypothesis

      -
      n = 500 # Number of simulations.
      test_statistics = np.array([]) # Array to keep track of the test statistic for each iteration.
      for i in np.arange(n): # Run the simulation `n` number of times
      # 1. Simulate the dogs distribution

      # Calculte the smaple size (number of dogs)
      sample_size = dogs_df.shape[0]

      # Under the null hypothesis, proportion of "white" dogs among dogs is equal to the proportion of white pets among the overall population
      model_proportions = np.array([obs_dogs_prop, 1-obs_dogs_prop])

      # Calculate the the proportion of white dogs among all dogs.
      simulation_proportion = np.random.multinomial(sample_size, model_proportions)[0] / sample_size

      # 2. Compute the test statistic
      test_stat = difference_in_proportions(simulation_proportion, overall_prop)

      # 3. Save the result
      test_statistics = np.append(test_statistics, test_stat)
      -

      This code will run the permutation test 500 times, but a different reasonable number can be used instead. It is crucial to keep track of the test statistic each time our for-loop runs so that the number of simulated values can be stored.

      +
      n = 500 # Number of simulations.
      test_statistics = np.array([]) # Array to keep track of the test statistic for each iteration.

      # Calculte the smaple size (number of dogs)
      sample_size = dogs_df.shape[0]

      # Under the null hypothesis, proportion of "white" dogs among dogs is equal to the proportion of white pets among the overall population
      model_proportions = np.array([obs_dogs_prop, 1-obs_dogs_prop])

      for i in np.arange(n): # Run the simulation `n` number of times

      # 1. Simulate the dogs distribution
      # Calculate the the proportion of white dogs among all dogs.
      simulation_proportion = np.random.multinomial(sample_size, model_proportions)[0] / sample_size

      # 2. Compute the test statistic
      test_stat = difference_in_proportions(simulation_proportion, overall_prop)

      # 3. Save the result
      test_statistics = np.append(test_statistics, test_stat)
      +

      This code will run the hypothesis test 500 times, but a different reasonable number can be used instead. It is crucial to keep track of the test statistic each time our for-loop runs so that the number of simulated values can be stored.


      6. Conclusion

      p_value = np.count_nonzero(test_statistics >= observed_stat) / n

      print("The observed value of the test statistic is:", observed_stat)
      print("The p-value is:", p_value)
      @@ -64,18 +65,45 @@

      7. Extra
      # Create the histogram.
      bpd.DataFrame().assign(test_statistics=test_statistics).plot(kind='hist', bins= 10, density=True, ec='w')
      # Don't worry about these lines - you won't need to know it for this course!
      plt.axvline(x=observed_stat, c='black', linewidth=4);
      yticks = plt.gca().get_yticks()
      plt.yticks(yticks, np.round(yticks * 0.1, 2))
      plt.show()

    Distribution

    -

    From this graph, we can see that more than half of the data are to the right of the black vertical line (our observed test statistic), meaning we have a relatively high p-value!

    +

    From this graph, we can see that more than half of the data are to the right of the black vertical line (our observed statistic), meaning we have a relatively high p-value!


    Code Example 2 (TVD)

    1. State the question/hypothesis

    We found that the color distribution of dogs seems different from that of all pets.

    -
    IndexPets_DistDogs_Dist
    black0.530.44
    golden0.210.11
    white0.260.44
    +
    IndexPets_DistDogs_Dist
    black0.530.44
    golden0.210.12
    white0.260.44

    To see whether this difference is due to random chance, we will test the following pair of hypotheses at the standard p = 0.05 significance level.

    Hypotheses
    • Null Hypothesis: The color distribution of dogs is the same as the color distribution of pets.
    • Alternative Hypothesis: The color distribution of dogs is different from the color distribution of pets.

    Since we are comparing two categorical distributions, we use Total Variation Distance (TVD) between the two distributions as our test statistic.

    -
    +
    +

    2. Create a function to calculate test statistic (TVD)

    +

    Create a function to calculate the test statistic during every trial of our hypothesis test.

    +
    def total_variation_distance(dist1, dist2):
    '''Computes the TVD between two categorical distributions,
    assuming the categories appear in the same order.'''
    return np.abs((dist1 - dist2)).sum() / 2
    +
    +

    4. Compute the observed statistic

    +
    pets_color_dist = np.array([0.53, 0.21, 0.26])
    dogs_color_dist = np.array([0.44, 0.12, 0.44])
    observed_tvd = total_variation_distance(dogs_color_dist, pets_color_dist)
    observed_tvd
    +

    0.18

    +
    +

    5. Simulate the hypothesis test under the null hypothesis

    +
    n = 5000 # Number of simulations.
    tvds = np.array([]) # Array to keep track of the test statistic for each iteration.

    # Get sample df (dogs df)
    dog_df = full_pets[full_pets.get('Species') == 'dog']

    # Calculte the smaple size (number of dogs)
    sample_size = dog_df.shape[0]

    for i in np.arange(n): # Run the simulation `n` number of times

    # 1. Simulate the color distribution of dogs.
    # Under the null hypothesis, color distribution of dogs should be equal to the color distribution of pets among the overall population
    sample_distribution = np.random.multinomial(sample_size, pets_color_dist) / sample_size

    # 2. Compute the test statistic (TVD)
    new_tvd = total_variation_distance(sample_distribution, pets_color_dist)

    # 3. Save the result
    tvds = np.append(tvds, new_tvd)
    +

    This code will run the hypothesis test 5000 times, but a different reasonable number can be used instead. It is crucial to keep track of the test statistic each time our for-loop runs so that the number of simulated values can be stored.

    +
    +

    6. Conclusion

    +
    p_value = np.count_nonzero(tvds >= observed_tvd) / n

    print("The observed value of the test statistic is:", observed_tvd)
    print("The p-value is:", p_value)
    +

    The observed value of the test statistic is: 0.18
    +The p-value is: 0.4972

    +

    Using a significance level of 0.05:

    +
    Conclusion
      +
    • Under the null hypothesis, there is a sufficiently large probability of seeing a difference greater than the observed value. The data are consistent with the null hypothesis.
    • +
    • Since our p-value is greater than 0.05, we fail to reject the null hypothesis.
    • +
    +
    +

    7. Extra

    +

    Let's see how our observed statistic compares to the overall simulated values!

    +
    # Create the histogram.
    bpd.DataFrame().assign(tvds=tvds).plot(kind='hist', density=True, bins=20, ec='w', figsize=(10, 5), title='Empirical Distribution of TVD Between Pets Colors and Dogs Colors')
    # Don't worry about these lines - you won't need to know it for this course!
    plt.axvline(observed_tvd, color='black', linewidth=4, label='Observed Statistic')
    plt.legend();
    +

    Distribution

    +

    From this graph, we can see that almost half of the data are to the right of the black vertical line (our observed statistic), meaning we have a relatively high p-value!

\ No newline at end of file diff --git a/docs/statistical-inference/intro/index.html b/docs/statistical-inference/intro/index.html index 36da6ab0..0ebe588a 100644 --- a/docs/statistical-inference/intro/index.html +++ b/docs/statistical-inference/intro/index.html @@ -11,7 +11,7 @@ - + diff --git a/docs/statistical-inference/null_and_alt/index.html b/docs/statistical-inference/null_and_alt/index.html index 05663829..6a71e915 100644 --- a/docs/statistical-inference/null_and_alt/index.html +++ b/docs/statistical-inference/null_and_alt/index.html @@ -11,7 +11,7 @@ - + diff --git a/docs/statistical-inference/obs_and_test_stats/index.html b/docs/statistical-inference/obs_and_test_stats/index.html index 16f5cae0..e889870d 100644 --- a/docs/statistical-inference/obs_and_test_stats/index.html +++ b/docs/statistical-inference/obs_and_test_stats/index.html @@ -11,7 +11,7 @@ - + @@ -29,36 +29,34 @@

1. Abs

Absolute difference in group mean/median/number of times a certain event happens.

  • ✅ Used for measuring how different two numerical distributions are, and when the alternative hypothesis is not equal to. For example, "the coin is biased" or "the probability of tossing a head is 0.5".
  • +
  • 💻 Example of using absolute difference as the test statistic in a permutation test.

2. Difference

Difference in group mean/median/number of times a certain event happens.

  • ✅ Used for measuring how different two numerical distributions are, and the alternative hypothesis is less than or greater than. For example, "the coin is biased towards heads" or "the probability of tossing a head is greater then 0.5".
  • +
  • 💻 Example of using difference as the test statistic in a hypothesis test.

3. Total Variation Distance (TVD)

A test statistic that quantifies how different two categorical distributions are by calculating the sum of the absolute differences of their proportions, all divided by 2.

  • ❌️ The TVD is not used for permutation tests.
  • ✅ Used for assessing whether an "observed sample" was drawn randomly from a known categorical distribution.
  • +
  • 💻 Example of using TVD as the test statistic in a hypothesis test.
-
#code implementation
def tvd(dist1, dist2):
return np.abs(dist1 - dist2).sum() / 2
-
note

3 Ways of Computing TVD: 🧮
-to do: use an example -Assume PiP_i is one distribution and QiQ_i is the other.

    +
    #code implementation
    def tvd(dist1, dist2):
    '''Computes the TVD between two categorical distributions,
    assuming the categories appear in the same order.'''
    return np.abs(dist1 - dist2).sum() / 2
    +
    note

    3 Ways of Manually Computing TVD: 🧮

    to do: use an example

    Assume PiP_i is one distribution and QiQ_i is the other, and the categories appear in the same order

    1. Follow the definition: Calculate the sum of the absolute differences of the two distributions' proportions, all divided by 2.
      TVD=12PiQi\text{TVD}=\frac{1}{2}\sum \mid P_i - Q_i\mid

    2. Sum of positive differences: Add only the values where one distribution (e.g. P_i) is greater than the other (e.g. Q_i) . This essentially sums the excessive probabilities in one distribution over the other.
      -TVD=max(PiQi,0)\text{TVD}=\sum max(P_i-Q_i,0) -to do: replace formula with example DataFrame visualization

      +TVD=max(PiQi,0)\text{TVD}=\sum max(P_i-Q_i,0)

    3. -
    4. -

      Sum of negative differences: Add only the absolute values where the selected distribution (e.g. P_i) is less than the other (e.g. Q_i). This essentially sums the deficient probabilities in one distribution relative to the other.
      -TVD=abs(min(PiQi,0))\text{TVD}=\sum abs(min(P_i-Q_i,0)) -to do: replace formula with example DataFrame visualization

      -
    5. -
+

to do: replace formula with example DataFrame visualization

    +
  1. Sum of negative differences: Add only the absolute values where the selected distribution (e.g. P_i) is less than the other (e.g. Q_i). This essentially sums the deficient probabilities in one distribution relative to the other.
    +TVD=abs(min(PiQi,0)) or TVD=max(QiPi,0)\text{TVD}=\sum abs(min(P_i-Q_i,0)) \ \text{or} \ \text{TVD}=\sum max(Q_i-P_i,0)
  2. +

to do: replace formula with example DataFrame visualization

\ No newline at end of file diff --git a/docs/statistical-inference/p_value/index.html b/docs/statistical-inference/p_value/index.html index d58f39ca..30a6ef87 100644 --- a/docs/statistical-inference/p_value/index.html +++ b/docs/statistical-inference/p_value/index.html @@ -11,7 +11,7 @@ - + diff --git a/docs/statistical-inference/parameters-and-statistics/index.html b/docs/statistical-inference/parameters-and-statistics/index.html index 424db0d4..6b53ed50 100644 --- a/docs/statistical-inference/parameters-and-statistics/index.html +++ b/docs/statistical-inference/parameters-and-statistics/index.html @@ -11,7 +11,7 @@ - + diff --git a/docs/statistical-inference/permutation_test/index.html b/docs/statistical-inference/permutation_test/index.html index 17035a04..3926aea8 100644 --- a/docs/statistical-inference/permutation_test/index.html +++ b/docs/statistical-inference/permutation_test/index.html @@ -11,7 +11,7 @@ - + @@ -30,7 +30,7 @@

The diagram below provides an overview of conducting a permutation test, although it references a different dataset. Here is another useful visualization. For additional helpful visual guides, please visit the Diagrams site.


-

Code Example

+

Code Example (Absolute Difference)

1. State the question/hypothesis

+

From this graph, we can tell that there is barely any data to the right of the black vertical line (our observed statistic), meaning we have a very low p-value!

\ No newline at end of file diff --git a/docs/statistical-inference/random sampling/df.sample()/index.html b/docs/statistical-inference/random sampling/df.sample()/index.html index 7cbf40d6..e001a29c 100644 --- a/docs/statistical-inference/random sampling/df.sample()/index.html +++ b/docs/statistical-inference/random sampling/df.sample()/index.html @@ -11,7 +11,7 @@ - + diff --git a/docs/statistical-inference/random sampling/np.random.choice()/index.html b/docs/statistical-inference/random sampling/np.random.choice()/index.html index d5a32468..49f5916a 100644 --- a/docs/statistical-inference/random sampling/np.random.choice()/index.html +++ b/docs/statistical-inference/random sampling/np.random.choice()/index.html @@ -11,7 +11,7 @@ - + diff --git a/docs/statistical-inference/random sampling/np.random.multinomial()/index.html b/docs/statistical-inference/random sampling/np.random.multinomial()/index.html index a9c15e26..dd7991b8 100644 --- a/docs/statistical-inference/random sampling/np.random.multinomial()/index.html +++ b/docs/statistical-inference/random sampling/np.random.multinomial()/index.html @@ -11,7 +11,7 @@ - + diff --git a/docs/statistical-inference/random sampling/np.random.permutation()/index.html b/docs/statistical-inference/random sampling/np.random.permutation()/index.html index b0c37c83..521cba83 100644 --- a/docs/statistical-inference/random sampling/np.random.permutation()/index.html +++ b/docs/statistical-inference/random sampling/np.random.permutation()/index.html @@ -11,7 +11,7 @@ - + diff --git a/docs/statistical-inference/random sampling/sampling/index.html b/docs/statistical-inference/random sampling/sampling/index.html index e4bfde88..ebd26c6b 100644 --- a/docs/statistical-inference/random sampling/sampling/index.html +++ b/docs/statistical-inference/random sampling/sampling/index.html @@ -11,7 +11,7 @@ - + diff --git a/docs/statistical-inference/standard_normal_distribution/index.html b/docs/statistical-inference/standard_normal_distribution/index.html index ca3ede40..1d321c5a 100644 --- a/docs/statistical-inference/standard_normal_distribution/index.html +++ b/docs/statistical-inference/standard_normal_distribution/index.html @@ -11,7 +11,7 @@ - + diff --git a/docs/statistical-inference/standard_units/index.html b/docs/statistical-inference/standard_units/index.html index 9903e9d2..c2d7262d 100644 --- a/docs/statistical-inference/standard_units/index.html +++ b/docs/statistical-inference/standard_units/index.html @@ -11,7 +11,7 @@ - + diff --git a/docs/tags/correlation/index.html b/docs/tags/correlation/index.html index a4e102d2..e34a30fc 100644 --- a/docs/tags/correlation/index.html +++ b/docs/tags/correlation/index.html @@ -11,7 +11,7 @@ - + diff --git a/docs/tags/for-loop/index.html b/docs/tags/for-loop/index.html index 5754ad8c..4d9f6378 100644 --- a/docs/tags/for-loop/index.html +++ b/docs/tags/for-loop/index.html @@ -11,7 +11,7 @@ - + diff --git a/docs/tags/functions/index.html b/docs/tags/functions/index.html index 0d94d1d5..6b07e9cc 100644 --- a/docs/tags/functions/index.html +++ b/docs/tags/functions/index.html @@ -11,7 +11,7 @@ - + diff --git a/docs/tags/histogram/index.html b/docs/tags/histogram/index.html index 585e523d..a68195c5 100644 --- a/docs/tags/histogram/index.html +++ b/docs/tags/histogram/index.html @@ -11,7 +11,7 @@ - + diff --git a/docs/tags/index.html b/docs/tags/index.html index 76ed1e3b..f0442d12 100644 --- a/docs/tags/index.html +++ b/docs/tags/index.html @@ -11,7 +11,7 @@ - + diff --git a/docs/tags/normal-distributions/index.html b/docs/tags/normal-distributions/index.html index 8643b031..d4e79fa6 100644 --- a/docs/tags/normal-distributions/index.html +++ b/docs/tags/normal-distributions/index.html @@ -11,7 +11,7 @@ - + diff --git a/docs/tags/querying/index.html b/docs/tags/querying/index.html index 923554b7..c3c8777c 100644 --- a/docs/tags/querying/index.html +++ b/docs/tags/querying/index.html @@ -11,7 +11,7 @@ - + diff --git a/docs/tags/regression/index.html b/docs/tags/regression/index.html index b2a57430..f432c921 100644 --- a/docs/tags/regression/index.html +++ b/docs/tags/regression/index.html @@ -11,7 +11,7 @@ - + diff --git a/docs/tags/standard-units/index.html b/docs/tags/standard-units/index.html index dc1feed4..7c2a1bec 100644 --- a/docs/tags/standard-units/index.html +++ b/docs/tags/standard-units/index.html @@ -11,7 +11,7 @@ - + diff --git a/img/statistical-inference-plots/hypothesis-test2.png b/img/statistical-inference-plots/hypothesis-test2.png new file mode 100644 index 0000000000000000000000000000000000000000..dc5d4c08e0cd6d7a6f1ad3e82c98bd2010bdd652 GIT binary patch literal 22439 zcmeIa2T+ySwl%udR@(rySwO&m0Z>q)WQ+s}l9i|;C>e>8v2CSQ1jT@Wf(nw8lCw67 zAOezwO_UrqImdsjZJ%@RdGFS(^XkbBr;^{O+7pmStGWvX(-j zFv!cDRHIN<^iU|v#(!OfpClYueF%Sv+MhaSuWoH(?{v}Dn4)yi-p0b(-oo_KPDf)~ zJ5y^b0bU{ABL{b0wYRsi6XWBv{O1dJt!=OHeZM%Giw{|2BX{18LSec{{#zC$9cfCT zXm6H3c}(N_b6S(r_05_~izBX8tZR00{;}~mQ?A_RWn8cR+`MJ;lhu++l9-hM`9_RfZEFVxFUdT$wwZ9VS z=2%wd@7n#9IrvE7ueb;bCF5~$>^l0tD8Ja#|2}xbi;?`pYvpg>mXUuXQI?C5zbRW~ zWLA^E-!K0aYl1)LD9hOB|5&&49lcoKVBKio`@n-pnr zQy=RpEvevVwv4@4a63jX)7H24(UV*2wwW|I?p1hvHh@>(s&~>VRVi3F`q<4?YuB#z zFEy#k9?A>03gOkyY8=jxcTKUVSHs7f)g|ahP|wK8JqQgAWq0Y>CEx2O&%wcQ%iEi0 z-@emt-@d);=T}}km$5i@HMxHCjvaA2sb;-ZD$=Djc@M*x1xzkys0?mi&A7wn`xPrI ztF>#^sNUOpD8-T1up`mBG)Ra=$}MAYraM$u=ZcwGjMUP+os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