Posts

Showing posts from September, 2017

How to convert milliseconds or seconds into date format in Presto?

Milliseconds: DATE_FORMAT(FROM_UNIXTIME(column_name /1000),'%Y-%m-%d') Seconds: DATE_FORMAT(FROM_UNIXTIME(column_name),'%Y-%m-%d') Please note that '/1000' should be added when it converts milliseconds to human-readable format.  We have the column " purchased_date_epoch " stored as numeric format. Let's say we want to convert the " purchased_date_epoch " column value " 1442287036 " to  human-readable  format.  SELECT purchased_date_epoch FROM table                               return: 144287036  SELECT DATE_FORMAT(FROM_UNIXTIME(purchased_date_epoch),'%Y-%m-%d %T) return: 2015-09-15 03:17:16                                          SELECT DATE_FORMAT(FROM_UNIXTIME(purchased_date_epoch),'%Y-%m-%d)    return: 2015-09-15                                                  

How to perform two-sample one-tailed t-test in Python

Image
In python, we can use ttest_ind   to perform two-sample one-tailed test. Assuming that our hypothesis are: Ho(Null Hypothesis): P1 >= P2 Ha(Alternative Hypothesis): P1< P2 In this case, we know that we have 1st normal distribution with mean equal to 3 and variance equal to 2 with 400 data points. The 2nd normal distribution has the mean equal to 6 but the same sigma and size as 1st normal distribution.  How can we interpret the results? According the  Stat Trek , when the null hypothesis is: 6>=3, the t score should be equal to 21.2 with degree freedom equal to 798 and SE equal to 0.1414. Stat Trek Calculator gives use the p-value equal to 1. You might notice that no matter whether or not we write  ttest_ind(P1,P2)   or  ttest_ind(P2,P1)  , the t-statistics changes but the p-value does not change. Why? By default, Python Scipy library does not give an option for us to perform one-tailed two sample test. The p-value is computed based on the assumption of two