<commit_before>Ext.namespace('GemmaStatUtils');
Ext.namespace('GemmaStatUtils.Constants');

GemmaStatUtils.Constants.MACHEP = 1.11022302462515654042E-16;
GemmaStatUtils.Constants.MAXLOG = 7.09782712893383996732E2;
GemmaStatUtils.Constants.MINLOG = -7.451332191019412076235E2;
GemmaStatUtils.Constants.MAXGAM = 171.624376956302725;
GemmaStatUtils.Constants.SQTPI = 2.50662827463100050242E0;
GemmaStatUtils.Constants.SQRTH = 7.07106781186547524401E-1;
GemmaStatUtils.Constants.LOGPI = 1.14472988584940017414;

GemmaStatUtils.Constants.BIG = 4.503599627370496e15;
GemmaStatUtils.Constants.BIG_INVERSE = 2.22044604925031308085e-16;

/**
 * Fisher's method for combining p values. (Cooper and Hedges 15-8)
 * 
 * @param pValues
 * @return double upper tail
 */
GemmaStatUtils.computeMetaPvalue = function (pValues) {
        var metaPvalue = 0.0;
        for (var i = 0; i < pValues.length; i++ ) {
        	metaPvalue += Math.log( pValues[i] );
        }
        metaPvalue *= -2.0;
        // NOTE: dof is first argument.
        return GemmaStatUtils.chiSquareComplemented( 2.0 * pValues.length, metaPvalue );    
};

GemmaStatUtils.chiSquareComplemented = function (v, x) {
  if (x < 0.0 || v < 1.0) {
    return 0.0;
  }
  return GemmaStatUtils.incompleteGammaComplement (v / 2.0, x / 2.0);
};

/**<commit_msg>temp fix for meta p-value calculation where all values are missing<commit_after>Ext.namespace('GemmaStatUtils');
Ext.namespace('GemmaStatUtils.Constants');

GemmaStatUtils.Constants.MACHEP = 1.11022302462515654042E-16;
GemmaStatUtils.Constants.MAXLOG = 7.09782712893383996732E2;
GemmaStatUtils.Constants.MINLOG = -7.451332191019412076235E2;
GemmaStatUtils.Constants.MAXGAM = 171.624376956302725;
GemmaStatUtils.Constants.SQTPI = 2.50662827463100050242E0;
GemmaStatUtils.Constants.SQRTH = 7.07106781186547524401E-1;
GemmaStatUtils.Constants.LOGPI = 1.14472988584940017414;

GemmaStatUtils.Constants.BIG = 4.503599627370496e15;
GemmaStatUtils.Constants.BIG_INVERSE = 2.22044604925031308085e-16;

/**
 * Fisher's method for combining p values. (Cooper and Hedges 15-8)
 * 
 * @param pValues
 * @return double upper tail
 */
GemmaStatUtils.computeMetaPvalue = function (pValues) {
	if (pValues.length == 0) {
		return 1.0;
	}
	
	var metaPvalue = 0.0;
        for (var i = 0; i < pValues.length; i++ ) {
        	metaPvalue += Math.log( pValues[i] );
        }
        metaPvalue *= -2.0;
        // NOTE: dof is first argument.
        return GemmaStatUtils.chiSquareComplemented( 2.0 * pValues.length, metaPvalue );    
};

GemmaStatUtils.chiSquareComplemented = function (v, x) {
  if (x < 0.0 || v < 1.0) {
    return 0.0;
  }
  return GemmaStatUtils.incompleteGammaComplement (v / 2.0, x / 2.0);
};

/**
{'fraction_non_alphanumeric': 0.12089937338739402, 'fraction_numerical': 0.15739034279395503, 'mean_word_length': 3.9616087751371114, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4267635', 'n_tokens_mistral': 1308, 'n_tokens_neox': 1054, 'n_words': 177}