Changeset 1553 for trunk/yat


Ignore:
Timestamp:
Oct 7, 2008, 6:06:50 PM (13 years ago)
Author:
Peter
Message:

fixes #450

Location:
trunk/yat/statistics
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/statistics/utility.cc

    r1487 r1553  
    4747    if (n<=2)
    4848      return std::numeric_limits<double>::quiet_NaN();
     49    if (r>=1.0)
     50      return 0.0;
     51    if (r<=-1.0)
     52      return 1.0;
    4953    return gsl_cdf_tdist_Q(r*sqrt((n-2)/(1-r*r)), n-2);
    5054  }
  • trunk/yat/statistics/utility.h

    r1500 r1553  
    100100
    101101     \return Probability that correlation is larger than \a r by
    102      chance when having \a n samples.
     102     chance when having \a n samples. For \a r larger or equal to 1.0,
     103     0.0 is returned. For \a r smaller or equal to -1.0, 1.0 is
     104     returned.
    103105   */
    104106  double pearson_p_value(double r, unsigned int n);
Note: See TracChangeset for help on using the changeset viewer.