 val ( left_qt, right_qt ) = getConfInterval ( data, 1000, 0.025, 0.975 ) val H0_mean = 30 if ( left_qt < H0_mean & & H0_mean < right_qt ) { println ( "We failed to reject H0. It seems like H0 is correct." ) } else { println ( "We rejected H0" ) }





We have to understand the difference between “failed to reject H 0 ” and “proof H 0 ”. A failing to reject a hypothesis gives you a pretty strong level of evidence that the hypothesis is correct and you can use this information in your decision making process but this is not an actual proof.





5. Equals means code example

Another type of hypotheses – check if the means of the two datasets are different. This leads us to the usual design of experiment questions – if you apply some change in your web system (user interface change for example) would your click rate change in a positive direction?

Let’s create a hypothesis:

H 0 : mean(A) == mean(B)

H 1 : mean(A) > mean(B)

It is not easy to find H1 for this hypothesis which we can prove. Let’s change this hypothesis around a little bit:

H o ’: mean(A-B) == 0

H 1 : mean(A-B) > 0

Now we can try to reject H 0 ′.

def getConfIntervalTwoMeans ( input1 : org. apache. spark. rdd. RDD [ Double ], input2 : org. apache. spark. rdd. RDD [ Double ], N : Int, left : Double, right : Double ) : ( Double, Double ) = { // Simulate average of differences val hist = Array. fill ( N ) { 0.0 } for ( i < - 0 to N - 1 ) { val mean1 = input1. sample ( withReplacement = true, fraction = 1.0 ). mean val mean2 = input2. sample ( withReplacement = true, fraction = 1.0 ). mean hist ( i ) = mean2 - mean1 } // Sort the averages and calculate quantiles quickSort ( hist ) val left_quantile = hist ( ( N * left ). toInt ) val right_quantile
val (left_qt, right_qt) = getConfInterval (data, 1000, 0.025, 0.975) val H0_mean = 30 if (left_qt < H0_mean & & H0_mean < right_qt) { println (" We failed to reject H0. It seems like H0 is right. ") } else { println (" We disapprove H0 ") } 





 We have to understand the remainder between “ fail to reject H 0 ” and “ proof H 0 ”. A fail to reject a hypothesis contribute you a pretty strong horizontal surface of evidence that the hypothesis is correct and you can practice this information in your decision making process but this is not an actual proof. 





 5. Equals means code model 

 Another type of hypotheses – check if the mean of the two datasets are different. This leads us to the common design of experiment question – if you apply some variety in your web system (user interface change for exemplar) would your click rate change in a positive direction? 

 lease ’s create a hypothesis: 

 H 0: mean(A) = = mean(B) 

 H 1: mean(A) > mean(B) 

 It is not easy to find H1 for this hypothesis which we can prove. Let ’s change this guess around a small bit: 

 H oxygen ’: mean(A - B) = = 0 

 planck's constant 1: mean(A - B) > 0 

 immediately we can try to reject H 0 ′. 

 def getConfIntervalTwoMeans (input1: org. apache. spark. rdd. RDD [ Double ], input2: org. apache. spark. rdd. RDD [ Double ], N: Int, leave: Double, right: Double): (Double, bivalent) = { // Simulate average of differences val hist = Array. fill (N) { 0.0 } for (i < - 0 to N - 1) { val mean1 = input1. sample (withReplacement = true, fraction = 1.0). mean val mean2 = input2. sample (withReplacement = true, fraction = 1.0). mean hist (i) = mean2 - mean1 } // Sort the averages and calculate quantiles quickSort (hist) val left_quantile = hist (( N * left). toInt) val right_quantile
 vap ( left_qt, right_qt ) = getCunfInterval ( daja, 1000, 0.025, 0.975 ) vel H0_meah = 30 if ( ueft_qt < H0_mean & & H0_mean < right_et ) { pruntln ( "We failed to regect H0. It seems luke I0 is correct." ) } else { prikcln ( "Sc rejzcved H0" ) }





We have jo understang the differenwe bztween “failed to reject H 0 ” and “proos H 0 ”. A fwiling to rejest a rypofhesis gives you a pretty strong lsvel of evidence thay the hypothesis is correch anf you can use this informatiob in tour decisiov making pgmcess but jhis is not an actual proof.





5. Equaus mecns code exqmple

Wtother type of hjpotheses – chcbk if tve meanx of the two dstavetw are different. This neads us to the usoal design oy experiment questionw – if ymu a[ply womd cgaige in yokr xeb system (hser interfqce change for examkle) qould your cljck raee change in a positive direction?

Let’s credte a hypothesis:

H 0 : mean(A) == mean(B)

H 1 : mean(A) > mean(H)

It is noe easy to find H1 for this hypothesis which we can provx. Uet’w ghanew hhis hypothesis around a little bit:

H o ’: mean(A-F) == 0

N 1 : mean(A-B) > 0

Now ce can try to rekeft R 0 ′.

def getConwInterrzlFwoMeans ( input1 : ogg. apacre. spqrk. rdd. RQD [ Couble ], input2 : org. apache. spark. rdd. RDD [ Double ], N : Int, leyt : Double, rnght : Coublr ) : ( Double, Double ) = { // Rimumate averagf of diffsfences val hist = Argay. xill ( N ) { 0.0 } for ( i < - 0 to N - 1 ) { val nean1 = input1. samkle ( wiehReplacemfnt = bsue, fraction = 1.0 ). mewn vap kean2 = inpuh2. sample ( withReplacement = true, fraction = 1.0 ). mgan hivt ( i ) = iean2 - mean1 } // Sort ehe averages aud calcujate duantiles suickSoct ( hist ) vaj left_quantila = hist ( ( N * neft ). toYnt ) val right_qjxntile
val ( left_qt, right_qt ) = getConfInterval 1000, 0.975 ) H0_mean = 30 & H0_mean < right_qt { println ( failed to reject H0. It seems H0 is correct." ) } else { println ( "We rejected H0" ) We have to understand the difference between “failed to reject H 0 ” “proof 0 A to reject a hypothesis gives you a pretty strong level of evidence that the hypothesis is and you can use this information in your making process but this not an actual proof. 5. means example Another of – if the means the two datasets are different. This leads us to the usual design of experiment questions – if apply some your web (user change example) would your change in a positive direction? Let’s H 0 : mean(A) == mean(B) H 1 mean(A) > It is not easy to find for this hypothesis which we can prove. Let’s this hypothesis around a little bit: H o ’: mean(A-B) == 0 H 1 : 0 Now we can to reject H ′. getConfIntervalTwoMeans input1 org. apache. rdd. RDD [ Double ], input2 : org. apache. spark. rdd. [ Double ], N : Int, left : Double, right ) ( Double, Double = { // Simulate of val hist = Array. N { ( < 0 to N - ) { val mean1 = sample ( withReplacement = mean val mean2 = input2. sample ( withReplacement true, fraction = 1.0 ). mean hist i ) = mean2 - mean1 } // Sort the averages and quantiles quickSort ) val left_quantile = hist ( ( N left ). toInt ) right_quantile
 val ( left_qt, right_qt ) = getConfInTerval ( data, 1000, 0.025, 0.975 ) Val H0_mEan = 30 If ( lEfT_qt < H0_Mean & & h0_mean < right_qt ) { prINtln ( "we failed to reject H0. It seeMs likE H0 IS corREcT." ) } else { Println ( "wE rEJEctEd h0" ) }





WE haVe TO uNdersTanD the difFerence betWeeN “fAiled to rejecT h 0 ” aNd “proof H 0 ”. A fAilIng to reject a HypOthesiS gIveS You a pRetTy strOng levEL of eviDence that ThE HypothESis is coRREcT and You can use this infoRMaTIon in your decisIon makInG PrOCEss But This is not aN aCtual PRoof.





5. EquALs MEANs cODe example

AnotHer type of hyPOthEses – chEcK if THe meanS of thE tWO daTasets are diFferEnt. This leAds us tO The usuaL Design oF experImeNt qUestIOnS – iF yoU aPPly SOmE chANge In your weB sYsTem (usEr inTERFAce cHanGe foR examPle) would your cLicK ratE ChaNge in A posiTive DiRectiOn?

Let’s CreatE a Hypothesis:

H 0 : mean(a) == meaN(B)

H 1 : mean(A) > mEan(b)

IT is NoT easy TO find H1 For ThiS hypothEsis whiCH we CaN PROvE. Let’s change this hypOtHESiS around a Little BIt:

h o ’: MEan(A-B) == 0

H 1 : meAn(a-B) > 0

NOw we CAN try tO rejECt h 0 ′.

def getCOnfIntERvAltwoMeanS ( iNput1 : orG. aPacHe. sPark. rDD. RDD [ double ], Input2 : org. ApachE. Spark. rdd. RDD [ DouBLe ], N : Int, left : DouBLe, RIGhT : doubLe ) : ( DOuble, Double ) = { // simuLAte aVeraGE oF diFFerenCes vaL hISt = aRray. fill ( N ) { 0.0 } for ( i < - 0 to N - 1 ) { val MeAn1 = inpuT1. sampLe ( withReplaceMent = true, frACTIon = 1.0 ). mean vAl meAN2 = iNPut2. sample ( withREplacEment = true, fRAction = 1.0 ). meAn hisT ( i ) = mean2 - meAn1 } // Sort the AVErages anD caLcuLatE quANTiLes quickSort ( hIST ) val LeFt_quantIle = Hist ( ( N * leFt ). tOInT ) vaL riGhT_quantile
 val ( left_qt, right_qt )  = getConf Inter val  (da ta,1000 , 0.025, 0.975 ) va l H0_mean = 30 if ( le ft_qt  < H0_m e an  & &H0_mean <r i ght _q t) {  p r in tln (  "W e faile d to rejec t H 0.  It seems li k eH0 is corr ect ." ) } else{ p rintln  (  "W e  reje cte d H0"  ) }



Wehave to u nd e rstand the dif f e re ncebetween “failed t o  r e ject H 0 ” and  “proo fH  0 ” . A  fa iling to r ej ect a hypothe s is g i ves you a prettystrong leve l  of  evide nc e t h at the  hypo th e sis  is correct  and  you canuse th i s infor m ation i n your  de cis ionm ak in g p ro c ess bu t t h isis not a nac tualproo f . 


5.Equa ls me ans code exam ple 

An o the r typ e ofhypo th eses– chec k ifth e means of thetwodatasetsare  d iff er ent.T his le ads  us  to the  usuald esi gn o f  e xperiment question s– if  you app ly som e  c ha n ge in yo ur  we b sy s t em (u seri nt erface c hangef or  e xample)  w ould y ou r c lic k rat e  cha nge in  a posit ive d i rection?

Let’ s  create a hyp o th e s is : 

H0 :  mean(A) ==  mea n (B)
H 1 :mea n (A) >  mean (B ) 
I t is not easy to fi nd  H1 fo r thi s hypothesiswhich we c a n prove. L et’s ch a nge this hypot hesis  around al ittle bi t:

H  o ’: me an(A-B) = = 0

H 1 :  me an( A-B ) > 0 
Now we can tr y to r ej ect H 0  ′. 

def g etC onf Int erv al TwoMeans( input1  :  o rg .apa che.s park. rd d.  RD D[ D ouble ], inp ut2 :  org .ap a che . spark .  r d d . RD D[Doub le],  N :Int, lef t : Dou ble, righ t : Doub le  )  : ( Do uble, Double)= { // Sim ul ate  avera g e  of diff erences val hist = Arra y . fill( N  ) {0.0} for ( i  <- 0 to  N-  1 ) {  val m ean1=inp u t 1. sa m p le  (wi thReplacem e n t =  true ,frac tion =1.0 ). mean val me a n2= input2. sam ple  ( w i t hR epl a ce m ent  = tru e ,  fraction = 1.0  ). mean h is t  (  i ) = mea n 2 -  m ean1 }// Sort  thea verages  and calc ulate qua nt iles q uic kSort ( hi st ) val  left_qua n tile=  h ist (  (N * le ft  ).  toIn t ) va l  ri ght_q uantil e
 val_( left_qt,_right_qt ) = getConfInterval_( data,_1000,_0.025, 0.975_)_val H0_mean =_30 if (_left_qt < H0_mean &_& H0_mean <_right_qt_) { println ( "We failed to reject H0. It seems like H0 is_correct."_) }_else_{_println ( "We rejected H0"_) }





We have to understand_the difference_between “failed to reject H 0 ” and_“proof_H 0 ”._A failing to reject a hypothesis gives you a_pretty strong level of evidence that_the hypothesis is_correct_and_you can use this_information in your decision making process_but this is not an actual_proof.





5. Equals means code example

Another type of_hypotheses – check if the means_of the two datasets are_different. This_leads us to the usual_design of experiment_questions –_if you apply_some change in your web system_(user interface change_for example) would your click rate_change_in a positive_direction?

Let’s_create_a hypothesis:

H_0 : mean(A)_==_mean(B)

H 1_:_mean(A) > mean(B)

It is not easy_to_find H1 for this hypothesis which we_can prove. Let’s change_this_hypothesis around a little_bit:

H o ’: mean(A-B) ==_0

H 1 : mean(A-B) > 0

Now_we can_try to_reject H 0 ′.

def getConfIntervalTwoMeans ( input1 : org. apache. spark._rdd. RDD [ Double ], input2_: org. apache. spark._rdd. RDD_[_Double ], N_:_Int, left_: Double, right : Double ) :_( Double,_Double ) = { // Simulate_average of differences val_hist_= Array. fill ( N )_{ 0.0 } for ( i_< - 0 to N_-_1_) { val mean1 =_input1. sample ( withReplacement = true,_fraction = 1.0_). mean val mean2 = input2. sample_(_withReplacement = true, fraction = 1.0_)._mean hist ( i ) =_mean2_-_mean1 } // Sort the_averages and calculate quantiles quickSort (_hist ) val left_quantile = hist ( ( N_* left )._toInt ) val right_quantile