~ubuntu-branches/ubuntu/saucy/python-scipy/saucy

« back to all changes in this revision

Viewing changes to scipy/special/cdflib/dt1.f

  • Committer: Bazaar Package Importer
  • Author(s): Ondrej Certik
  • Date: 2008-06-16 22:58:01 UTC
  • mfrom: (2.1.24 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080616225801-irdhrpcwiocfbcmt
Tags: 0.6.0-12
* The description updated to match the current SciPy (Closes: #489149).
* Standards-Version bumped to 3.8.0 (no action needed)
* Build-Depends: netcdf-dev changed to libnetcdf-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
      DOUBLE PRECISION FUNCTION dt1(p,q,df)
 
2
C**********************************************************************
 
3
C
 
4
C     DOUBLE PRECISION FUNCTION DT1(P,Q,DF)
 
5
C     Double precision Initalize Approximation to
 
6
C           INVerse of the cumulative T distribution
 
7
C
 
8
C
 
9
C                              Function
 
10
C
 
11
C
 
12
C     Returns  the  inverse   of  the T   distribution   function, i.e.,
 
13
C     the integral from 0 to INVT of the T density is P. This is an
 
14
C     initial approximation
 
15
C
 
16
C
 
17
C                              Arguments
 
18
C
 
19
C
 
20
C     P --> The p-value whose inverse from the T distribution is
 
21
C          desired.
 
22
C                    P is DOUBLE PRECISION
 
23
C
 
24
C     Q --> 1-P.
 
25
C                    Q is DOUBLE PRECISION
 
26
C
 
27
C     DF --> Degrees of freedom of the T distribution.
 
28
C                    DF is DOUBLE PRECISION
 
29
C
 
30
C**********************************************************************
 
31
C
 
32
C     .. Scalar Arguments ..
 
33
      DOUBLE PRECISION df,p,q
 
34
C     ..
 
35
C     .. Local Scalars ..
 
36
      DOUBLE PRECISION denpow,sum,term,x,xp,xx
 
37
      INTEGER i
 
38
C     ..
 
39
C     .. Local Arrays ..
 
40
      DOUBLE PRECISION coef(5,4),denom(4)
 
41
      INTEGER ideg(4)
 
42
C     ..
 
43
C     .. External Functions ..
 
44
      DOUBLE PRECISION dinvnr,devlpl
 
45
      EXTERNAL dinvnr,devlpl
 
46
C     ..
 
47
C     .. Intrinsic Functions ..
 
48
      INTRINSIC abs
 
49
C     ..
 
50
C     .. Data statements ..
 
51
      DATA (coef(i,1),i=1,5)/1.0D0,1.0D0,3*0.0D0/
 
52
      DATA (coef(i,2),i=1,5)/3.0D0,16.0D0,5.0D0,2*0.0D0/
 
53
      DATA (coef(i,3),i=1,5)/-15.0D0,17.0D0,19.0D0,3.0D0,0.0D0/
 
54
      DATA (coef(i,4),i=1,5)/-945.0D0,-1920.0D0,1482.0D0,776.0D0,79.0D0/
 
55
      DATA ideg/2,3,4,5/
 
56
      DATA denom/4.0D0,96.0D0,384.0D0,92160.0D0/
 
57
C     ..
 
58
C     .. Executable Statements ..
 
59
      x = abs(dinvnr(p,q))
 
60
      xx = x*x
 
61
      sum = x
 
62
      denpow = 1.0D0
 
63
      DO 10,i = 1,4
 
64
          term = devlpl(coef(1,i),ideg(i),xx)*x
 
65
          denpow = denpow*df
 
66
          sum = sum + term/ (denpow*denom(i))
 
67
   10 CONTINUE
 
68
      IF (.NOT. (p.GE.0.5D0)) GO TO 20
 
69
      xp = sum
 
70
      GO TO 30
 
71
 
 
72
   20 xp = -sum
 
73
   30 dt1 = xp
 
74
      RETURN
 
75
 
 
76
      END