spm_Xcdf.m 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. function F = spm_Xcdf(x,v)
  2. % Cumulative Distribution Function (CDF) of Chi-squared distribution
  3. % FORMAT F = spm_Xcdf(x,v)
  4. %
  5. % x - Chi-squared variate
  6. % v - degrees of freedom (v>0, non-integer d.f. accepted)
  7. % F - CDF at x of Chi-squared distribution with v degrees of freedom
  8. %__________________________________________________________________________
  9. %
  10. % spm_Xcdf implements the Cumulative Distribution of Chi-squared
  11. % distributions.
  12. %
  13. % Returns the probability p, that a Students Chi-squared variate on v
  14. % degrees of freedom is less than x. F(x) = Pr{X<x} for X~\Chi^2(v)
  15. %
  16. % Definition:
  17. %--------------------------------------------------------------------------
  18. % The Chi-squared distribution with v degrees of freedom is defined for
  19. % positive integer v and x in [0,Inf). The Cumulative Distribution
  20. % Function (CDF) F(x) is the probability that a realisation of a
  21. % Chi-squared random variable X has value less than x. F(x)=Pr{X<x}:
  22. % (See Evans et al., Ch8)
  23. %
  24. % Variate relationships: (Evans et al., Ch8 & Ch18)
  25. %--------------------------------------------------------------------------
  26. % The Chi-squared distribution with v degrees of freedom is equivalent to
  27. % the Gamma distribution with scale parameter 1/2 and shape parameter v/2.
  28. %
  29. % Algorithm:
  30. %--------------------------------------------------------------------------
  31. % Using routine spm_Gcdf for Gamma distribution, with appropriate parameters.
  32. %
  33. % References:
  34. %--------------------------------------------------------------------------
  35. % Evans M, Hastings N, Peacock B (1993)
  36. % "Statistical Distributions"
  37. % 2nd Ed. Wiley, New York
  38. %
  39. % Abramowitz M, Stegun IA, (1964)
  40. % "Handbook of Mathematical Functions"
  41. % US Government Printing Office
  42. %
  43. % Press WH, Teukolsky SA, Vetterling AT, Flannery BP (1992)
  44. % "Numerical Recipes in C"
  45. % Cambridge
  46. %
  47. %__________________________________________________________________________
  48. % Copyright (C) 1992-2011 Wellcome Trust Centre for Neuroimaging
  49. % Andrew Holmes
  50. % $Id: spm_Xcdf.m 4182 2011-02-01 12:29:09Z guillaume $
  51. %-Check enough arguments
  52. %--------------------------------------------------------------------------
  53. if nargin<2, error('Insufficient arguments'), end
  54. %-Computation
  55. %--------------------------------------------------------------------------
  56. F = spm_Gcdf(x,v/2,1/2);