blob: 068d8f29b1f7de30b9c6b74272487440df97cd83 [file] [log] [blame]
"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[3218],{15680:(e,t,n)=>{n.d(t,{xA:()=>g,yg:()=>y});var a=n(96540);function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function o(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?s(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):s(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function l(e,t){if(null==e)return{};var n,a,r=function(e,t){if(null==e)return{};var n,a,r={},s=Object.keys(e);for(a=0;a<s.length;a++)n=s[a],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(a=0;a<s.length;a++)n=s[a],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var p=a.createContext({}),i=function(e){var t=a.useContext(p),n=t;return e&&(n="function"==typeof e?e(t):o(o({},t),e)),n},g=function(e){var t=i(e.components);return a.createElement(p.Provider,{value:t},e.children)},c="mdxType",u={inlineCode:"code",wrapper:function(e){var t=e.children;return a.createElement(a.Fragment,{},t)}},m=a.forwardRef((function(e,t){var n=e.components,r=e.mdxType,s=e.originalType,p=e.parentName,g=l(e,["components","mdxType","originalType","parentName"]),c=i(n),m=r,y=c["".concat(p,".").concat(m)]||c[m]||u[m]||s;return n?a.createElement(y,o(o({ref:t},g),{},{components:n})):a.createElement(y,o({ref:t},g))}));function y(e,t){var n=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var s=n.length,o=new Array(s);o[0]=m;var l={};for(var p in t)hasOwnProperty.call(t,p)&&(l[p]=t[p]);l.originalType=e,l[c]="string"==typeof e?e:r,o[1]=l;for(var i=2;i<s;i++)o[i]=n[i];return a.createElement.apply(null,o)}return a.createElement.apply(null,n)}m.displayName="MDXCreateElement"},87481:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>g,contentTitle:()=>p,default:()=>y,frontMatter:()=>l,metadata:()=>i,toc:()=>c});var a=n(58168),r=n(98587),s=(n(96540),n(15680)),o=["components"],l={id:"test-stats",title:"Test Stats Aggregators"},p=void 0,i={unversionedId:"development/extensions-core/test-stats",id:"development/extensions-core/test-stats",title:"Test Stats Aggregators",description:"\x3c!--",source:"@site/docs/latest/development/extensions-core/test-stats.md",sourceDirName:"development/extensions-core",slug:"/development/extensions-core/test-stats",permalink:"/docs/latest/development/extensions-core/test-stats",draft:!1,tags:[],version:"current",frontMatter:{id:"test-stats",title:"Test Stats Aggregators"}},g={},c=[{value:"Z-Score for two sample ztests post aggregator",id:"z-score-for-two-sample-ztests-post-aggregator",level:2},{value:"zscore2sample post aggregator",id:"zscore2sample-post-aggregator",level:3},{value:"pvalue2tailedZtest post aggregator",id:"pvalue2tailedztest-post-aggregator",level:3},{value:"Example Usage",id:"example-usage",level:2}],u={toc:c},m="wrapper";function y(e){var t=e.components,n=(0,r.A)(e,o);return(0,s.yg)(m,(0,a.A)({},u,n,{components:t,mdxType:"MDXLayout"}),(0,s.yg)("p",null,"This Apache Druid extension incorporates test statistics related aggregators, including z-score and p-value. Please refer to ",(0,s.yg)("a",{parentName:"p",href:"https://www.paypal-engineering.com/2017/06/29/democratizing-experimentation-data-for-product-innovations/"},"https://www.paypal-engineering.com/2017/06/29/democratizing-experimentation-data-for-product-innovations/")," for math background and details."),(0,s.yg)("p",null,"Make sure to include ",(0,s.yg)("inlineCode",{parentName:"p"},"druid-stats")," extension in order to use these aggregators."),(0,s.yg)("h2",{id:"z-score-for-two-sample-ztests-post-aggregator"},"Z-Score for two sample ztests post aggregator"),(0,s.yg)("p",null,"Please refer to ",(0,s.yg)("a",{parentName:"p",href:"https://www.isixsigma.com/tools-templates/hypothesis-testing/making-sense-two-proportions-test/"},"https://www.isixsigma.com/tools-templates/hypothesis-testing/making-sense-two-proportions-test/")," and ",(0,s.yg)("a",{parentName:"p",href:"http://www.ucs.louisiana.edu/~jcb0773/Berry_statbook/Berry_statbook_chpt6.pdf"},"http://www.ucs.louisiana.edu/~jcb0773/Berry_statbook/Berry_statbook_chpt6.pdf")," for more details."),(0,s.yg)("p",null,"z = (p1\xa0- p2) / S.E. (assuming null hypothesis is true)"),(0,s.yg)("p",null,"Please see below for p1 and p2.\nPlease note S.E. stands for standard error where"),(0,s.yg)("p",null,"S.E. = sqrt{ p1 ",(0,s.yg)("em",{parentName:"p"}," ( 1 - p1 )/n1 + p2 ")," (1 - p2)/n2) }"),(0,s.yg)("p",null,"(p1 \u2013 p2) is the observed difference between two sample proportions."),(0,s.yg)("h3",{id:"zscore2sample-post-aggregator"},"zscore2sample post aggregator"),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},(0,s.yg)("inlineCode",{parentName:"strong"},"zscore2sample")),": calculate the z-score using two-sample z-test while converting binary variables (",(0,s.yg)("strong",{parentName:"li"},(0,s.yg)("em",{parentName:"strong"},"e.g."))," success or not) to continuous variables (",(0,s.yg)("strong",{parentName:"li"},(0,s.yg)("em",{parentName:"strong"},"e.g."))," conversion rate).")),(0,s.yg)("pre",null,(0,s.yg)("code",{parentName:"pre",className:"language-json"},'{\n "type": "zscore2sample",\n "name": "<output_name>",\n "successCount1": <post_aggregator> success count of sample 1,\n "sample1Size": <post_aggregaror> sample 1 size,\n "successCount2": <post_aggregator> success count of sample 2,\n "sample2Size" : <post_aggregator> sample 2 size\n}\n')),(0,s.yg)("p",null,"Please note the post aggregator will be converting binary variables to continuous variables for two population proportions. Specifically"),(0,s.yg)("p",null,"p1 = (successCount1) / (sample size 1)"),(0,s.yg)("p",null,"p2 = (successCount2) / (sample size 2)"),(0,s.yg)("h3",{id:"pvalue2tailedztest-post-aggregator"},"pvalue2tailedZtest post aggregator"),(0,s.yg)("ul",null,(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},(0,s.yg)("inlineCode",{parentName:"strong"},"pvalue2tailedZtest")),": calculate p-value of two-sided z-test from zscore",(0,s.yg)("ul",{parentName:"li"},(0,s.yg)("li",{parentName:"ul"},(0,s.yg)("strong",{parentName:"li"},(0,s.yg)("em",{parentName:"strong"},"pvalue2tailedZtest(zscore)"))," - the input is a z-score which can be calculated using the zscore2sample post aggregator")))),(0,s.yg)("pre",null,(0,s.yg)("code",{parentName:"pre",className:"language-json"},'{\n "type": "pvalue2tailedZtest",\n "name": "<output_name>",\n "zScore": <zscore post_aggregator>\n}\n')),(0,s.yg)("h2",{id:"example-usage"},"Example Usage"),(0,s.yg)("p",null,"In this example, we use zscore2sample post aggregator to calculate z-score, and then feed the z-score to pvalue2tailedZtest post aggregator to calculate p-value."),(0,s.yg)("p",null,"A JSON query example can be as follows:"),(0,s.yg)("pre",null,(0,s.yg)("code",{parentName:"pre",className:"language-json"},'{\n ...\n "postAggregations" : {\n "type" : "pvalue2tailedZtest",\n "name" : "pvalue",\n "zScore" :\n {\n "type" : "zscore2sample",\n "name" : "zscore",\n "successCount1" :\n { "type" : "constant",\n "name" : "successCountFromPopulation1Sample",\n "value" : 300\n },\n "sample1Size" :\n { "type" : "constant",\n "name" : "sampleSizeOfPopulation1",\n "value" : 500\n },\n "successCount2":\n { "type" : "constant",\n "name" : "successCountFromPopulation2Sample",\n "value" : 450\n },\n "sample2Size" :\n { "type" : "constant",\n "name" : "sampleSizeOfPopulation2",\n "value" : 600\n }\n }\n }\n}\n\n')))}y.isMDXComponent=!0}}]);