def summary(self): """Summary of test, containing statistic, p-value and critical values """ table_data = [('Test Statistic', '{0:0.3f}'.format(self.stat)), ('P-value', '{0:0.3f}'.format(self.pvalue)), ('Lags', '{0:d}'.format(self.lags))] title = self._title if not title: title = self._test_name + " Results" table = SimpleTable(table_data, stubs=None, title=title, colwidths=18, datatypes=[0, 1], data_aligns=("l", "r")) smry = Summary() smry.tables.append(table) cv_string = 'Critical Values: ' cv = self._critical_values.keys() cv_numeric = array(lmap(lambda x: float(x.split('%')[0]), cv)) cv_numeric = sort(cv_numeric) for val in cv_numeric: p = str(int(val)) + '%' cv_string += '{0:0.2f}'.format(self._critical_values[p]) cv_string += ' (' + p + ')' if val != cv_numeric[-1]: cv_string += ', ' extra_text = [ 'Trend: ' + TREND_DESCRIPTION[self._trend], cv_string, 'Null Hypothesis: ' + self.null_hypothesis, 'Alternative Hypothesis: ' + self.alternative_hypothesis ] smry.add_extra_txt(extra_text) if self._summary_text: smry.add_extra_txt(self._summary_text) return smry
def summary(self): """Summary of test, containing statistic, p-value and critical values """ table_data = [('Test Statistic', '{0:0.3f}'.format(self.stat)), ('P-value', '{0:0.3f}'.format(self.pvalue)), ('Lags', '{0:d}'.format(self.lags))] title = self._title if not title: title = self._test_name + " Results" table = SimpleTable(table_data, stubs=None, title=title, colwidths=18, datatypes=[0, 1], data_aligns=("l", "r")) smry = Summary() smry.tables.append(table) cv_string = 'Critical Values: ' cv = self._critical_values.keys() cv_numeric = array(lmap(lambda x: float(x.split('%')[0]), cv)) cv_numeric = sort(cv_numeric) for val in cv_numeric: p = str(int(val)) + '%' cv_string += '{0:0.2f}'.format(self._critical_values[p]) cv_string += ' (' + p + ')' if val != cv_numeric[-1]: cv_string += ', ' extra_text = ['Trend: ' + TREND_DESCRIPTION[self._trend], cv_string, 'Null Hypothesis: ' + self.null_hypothesis, 'Alternative Hypothesis: ' + self.alternative_hypothesis] smry.add_extra_txt(extra_text) if self._summary_text: smry.add_extra_txt(self._summary_text) return smry
for i, t in enumerate(T): print("Time series length {0} for Trend {1}".format(t, tr)) now = datetime.datetime.now() # Serial version # out = lmap(wrapper, [t] * EX_NUM, [tr] * EX_NUM, # [EX_SIZE] * EX_NUM, seeds) # Parallel version res = lview.map_async(wrapper, [t] * EX_NUM, [tr] * EX_NUM, [EX_SIZE] * EX_NUM, seeds) sleep_count = 0 while not res.ready(): sleep_count += 1 elapsed = datetime.datetime.now() - now if sleep_count % 10: print('Elapsed time {0}, waiting for results'.format(elapsed, SLEEP)) time.sleep(SLEEP) out = res.get() # Prevent unnecessary results from accumulating clear_cache(rc, lview) elapsed = datetime.datetime.now() - now print('Total time {0} for T={1}'.format(elapsed, t)) quantiles = lmap(lambda x: percentile(x, percentiles), out) results[:, i, :] = array(quantiles).T savez(filename, trend=tr, results=results, percentiles=percentiles, T=T)
for i, t in enumerate(T): print("Time series length {0} for Trend {1}".format(t, tr)) now = datetime.datetime.now() # Serial version # out = lmap(wrapper, [t] * EX_NUM, [tr] * EX_NUM, # [EX_SIZE] * EX_NUM, seeds) # Parallel version res = lview.map_async(wrapper, [t] * EX_NUM, [tr] * EX_NUM, [EX_SIZE] * EX_NUM, seeds) sleep_count = 0 while not res.ready(): sleep_count += 1 elapsed = datetime.datetime.now() - now if sleep_count % 10: print('Elapsed time {0}, waiting for results'.format(elapsed, SLEEP)) time.sleep(SLEEP) out = res.get() # Prevent unnecessary results from accumulating clear_cache(rc, lview) elapsed = datetime.datetime.now() - now print('Total time {0} for T={1}'.format(elapsed, t)) q = lambda x: percentile(x, percentiles) quantiles = lmap(q, out) results[:, i, :] = array(quantiles).T savez(filename, trend=tr, results=results, percentiles=percentiles, T=T)