# TMVA::Tools::GetCorrelationRatio() returns a value larger than 1

**URL:** <https://root-forum.cern.ch/t/tmva-tools-getcorrelationratio-returns-a-value-larger-than-1/19649>\
**Category:** TMVA\
**Created:** [August 6, 2015, 11:40am UTC](https://root-forum.cern.ch/t/tmva-tools-getcorrelationratio-returns-a-value-larger-than-1/19649 "2015-08-06T11:40:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![noafeld](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/n/ce73a5/32.png) [@noafeld](https://root-forum.cern.ch/u/noafeld)\
**Post date:** [August 6, 2015, 11:40am UTC](https://root-forum.cern.ch/t/tmva-tools-getcorrelationratio-returns-a-value-larger-than-1/19649/1 "2015-08-06T11:40:55Z")

</div>

Hi,  
I’m Trying to get the correlation ratio for my TH2F, and I encountered this problem. This is my code:

```auto
TMVA::Tools & tmvaInstace = TMVA::Tools::Instance();

TFile file(<file_name>);
TH2F *hist;
file.GetObject(<histogram_name>, hist);
const TH2F &constHistRef = *hist;

cout << "Correlaton ratio: " << tmvaInstace.GetCorrelationRatio(constHistRef) << endl;
```

The value I get from the method is 1.02180220974304570e+00, which is statistically impossible… What am I doing wrong? I tried removing the ‘const’ decleration from constHistRef, but got no change.

Thank you!

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [August 10, 2015, 8:48am UTC](https://root-forum.cern.ch/t/tmva-tools-getcorrelationratio-returns-a-value-larger-than-1/19649/2 "2015-08-10T08:48:41Z")

</div>

Hi,

I am not sure what exactly is what you want to compute. Do you have a mathematical formula ?

If you want the sample correlation coefficient between the x and y variable  
(see definition at [en.wikipedia.org/wiki/Correlati … dependence](https://en.wikipedia.org/wiki/Correlation_and_dependence)),  
you should use TH2::GetCorrelationFactor()

Lorenzo
