Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/22/10 00:44:01 (14 years ago)
Author:
swagner
Message:

Sorted usings and removed unused usings in entire solution (#1094)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.ALGLIB/2.5.0/ALGLIB-2.5.0/fdistr.cs

    r3839 r4068  
    2626*************************************************************************/
    2727
    28 using System;
    2928
    30 namespace alglib
    31 {
    32     public class fdistr
    33     {
    34         /*************************************************************************
    35         F distribution
     29namespace alglib {
     30  public class fdistr {
     31    /*************************************************************************
     32    F distribution
    3633
    37         Returns the area from zero to x under the F density
    38         function (also known as Snedcor's density or the
    39         variance ratio density).  This is the density
    40         of x = (u1/df1)/(u2/df2), where u1 and u2 are random
    41         variables having Chi square distributions with df1
    42         and df2 degrees of freedom, respectively.
    43         The incomplete beta integral is used, according to the
    44         formula
     34    Returns the area from zero to x under the F density
     35    function (also known as Snedcor's density or the
     36    variance ratio density).  This is the density
     37    of x = (u1/df1)/(u2/df2), where u1 and u2 are random
     38    variables having Chi square distributions with df1
     39    and df2 degrees of freedom, respectively.
     40    The incomplete beta integral is used, according to the
     41    formula
    4542
    46         P(x) = incbet( df1/2, df2/2, (df1*x/(df2 + df1*x) ).
     43    P(x) = incbet( df1/2, df2/2, (df1*x/(df2 + df1*x) ).
    4744
    4845
    49         The arguments a and b are greater than zero, and x is
    50         nonnegative.
     46    The arguments a and b are greater than zero, and x is
     47    nonnegative.
    5148
    52         ACCURACY:
     49    ACCURACY:
    5350
    54         Tested at random points (a,b,x).
     51    Tested at random points (a,b,x).
    5552
    56                        x     a,b                     Relative error:
    57         arithmetic  domain  domain     # trials      peak         rms
    58            IEEE      0,1    0,100       100000      9.8e-15     1.7e-15
    59            IEEE      1,5    0,100       100000      6.5e-15     3.5e-16
    60            IEEE      0,1    1,10000     100000      2.2e-11     3.3e-12
    61            IEEE      1,5    1,10000     100000      1.1e-11     1.7e-13
     53                   x     a,b                     Relative error:
     54    arithmetic  domain  domain     # trials      peak         rms
     55       IEEE      0,1    0,100       100000      9.8e-15     1.7e-15
     56       IEEE      1,5    0,100       100000      6.5e-15     3.5e-16
     57       IEEE      0,1    1,10000     100000      2.2e-11     3.3e-12
     58       IEEE      1,5    1,10000     100000      1.1e-11     1.7e-13
    6259
    63         Cephes Math Library Release 2.8:  June, 2000
    64         Copyright 1984, 1987, 1995, 2000 by Stephen L. Moshier
    65         *************************************************************************/
    66         public static double fdistribution(int a,
    67             int b,
    68             double x)
    69         {
    70             double result = 0;
    71             double w = 0;
     60    Cephes Math Library Release 2.8:  June, 2000
     61    Copyright 1984, 1987, 1995, 2000 by Stephen L. Moshier
     62    *************************************************************************/
     63    public static double fdistribution(int a,
     64        int b,
     65        double x) {
     66      double result = 0;
     67      double w = 0;
    7268
    73             System.Diagnostics.Debug.Assert(a>=1 & b>=1 & (double)(x)>=(double)(0), "Domain error in FDistribution");
    74             w = a*x;
    75             w = w/(b+w);
    76             result = ibetaf.incompletebeta(0.5*a, 0.5*b, w);
    77             return result;
    78         }
     69      System.Diagnostics.Debug.Assert(a >= 1 & b >= 1 & (double)(x) >= (double)(0), "Domain error in FDistribution");
     70      w = a * x;
     71      w = w / (b + w);
     72      result = ibetaf.incompletebeta(0.5 * a, 0.5 * b, w);
     73      return result;
     74    }
    7975
    8076
    81         /*************************************************************************
    82         Complemented F distribution
     77    /*************************************************************************
     78    Complemented F distribution
    8379
    84         Returns the area from x to infinity under the F density
    85         function (also known as Snedcor's density or the
    86         variance ratio density).
     80    Returns the area from x to infinity under the F density
     81    function (also known as Snedcor's density or the
     82    variance ratio density).
    8783
    8884
    89                              inf.
    90                               -
    91                      1       | |  a-1      b-1
    92         1-P(x)  =  ------    |   t    (1-t)    dt
    93                    B(a,b)  | |
    94                             -
    95                              x
     85                         inf.
     86                          -
     87                 1       | |  a-1      b-1
     88    1-P(x)  =  ------    |   t    (1-t)    dt
     89               B(a,b)  | |
     90                        -
     91                         x
    9692
    9793
    98         The incomplete beta integral is used, according to the
    99         formula
     94    The incomplete beta integral is used, according to the
     95    formula
    10096
    101         P(x) = incbet( df2/2, df1/2, (df2/(df2 + df1*x) ).
     97    P(x) = incbet( df2/2, df1/2, (df2/(df2 + df1*x) ).
    10298
    10399
    104         ACCURACY:
     100    ACCURACY:
    105101
    106         Tested at random points (a,b,x) in the indicated intervals.
    107                        x     a,b                     Relative error:
    108         arithmetic  domain  domain     # trials      peak         rms
    109            IEEE      0,1    1,100       100000      3.7e-14     5.9e-16
    110            IEEE      1,5    1,100       100000      8.0e-15     1.6e-15
    111            IEEE      0,1    1,10000     100000      1.8e-11     3.5e-13
    112            IEEE      1,5    1,10000     100000      2.0e-11     3.0e-12
     102    Tested at random points (a,b,x) in the indicated intervals.
     103                   x     a,b                     Relative error:
     104    arithmetic  domain  domain     # trials      peak         rms
     105       IEEE      0,1    1,100       100000      3.7e-14     5.9e-16
     106       IEEE      1,5    1,100       100000      8.0e-15     1.6e-15
     107       IEEE      0,1    1,10000     100000      1.8e-11     3.5e-13
     108       IEEE      1,5    1,10000     100000      2.0e-11     3.0e-12
    113109
    114         Cephes Math Library Release 2.8:  June, 2000
    115         Copyright 1984, 1987, 1995, 2000 by Stephen L. Moshier
    116         *************************************************************************/
    117         public static double fcdistribution(int a,
    118             int b,
    119             double x)
    120         {
    121             double result = 0;
    122             double w = 0;
     110    Cephes Math Library Release 2.8:  June, 2000
     111    Copyright 1984, 1987, 1995, 2000 by Stephen L. Moshier
     112    *************************************************************************/
     113    public static double fcdistribution(int a,
     114        int b,
     115        double x) {
     116      double result = 0;
     117      double w = 0;
    123118
    124             System.Diagnostics.Debug.Assert(a>=1 & b>=1 & (double)(x)>=(double)(0), "Domain error in FCDistribution");
    125             w = b/(b+a*x);
    126             result = ibetaf.incompletebeta(0.5*b, 0.5*a, w);
    127             return result;
    128         }
     119      System.Diagnostics.Debug.Assert(a >= 1 & b >= 1 & (double)(x) >= (double)(0), "Domain error in FCDistribution");
     120      w = b / (b + a * x);
     121      result = ibetaf.incompletebeta(0.5 * b, 0.5 * a, w);
     122      return result;
     123    }
    129124
    130125
    131         /*************************************************************************
    132         Inverse of complemented F distribution
     126    /*************************************************************************
     127    Inverse of complemented F distribution
    133128
    134         Finds the F density argument x such that the integral
    135         from x to infinity of the F density is equal to the
    136         given probability p.
     129    Finds the F density argument x such that the integral
     130    from x to infinity of the F density is equal to the
     131    given probability p.
    137132
    138         This is accomplished using the inverse beta integral
    139         function and the relations
     133    This is accomplished using the inverse beta integral
     134    function and the relations
    140135
    141              z = incbi( df2/2, df1/2, p )
    142              x = df2 (1-z) / (df1 z).
     136         z = incbi( df2/2, df1/2, p )
     137         x = df2 (1-z) / (df1 z).
    143138
    144         Note: the following relations hold for the inverse of
    145         the uncomplemented F distribution:
     139    Note: the following relations hold for the inverse of
     140    the uncomplemented F distribution:
    146141
    147              z = incbi( df1/2, df2/2, p )
    148              x = df2 z / (df1 (1-z)).
     142         z = incbi( df1/2, df2/2, p )
     143         x = df2 z / (df1 (1-z)).
    149144
    150         ACCURACY:
     145    ACCURACY:
    151146
    152         Tested at random points (a,b,p).
     147    Tested at random points (a,b,p).
    153148
    154                      a,b                     Relative error:
    155         arithmetic  domain     # trials      peak         rms
    156          For p between .001 and 1:
    157            IEEE     1,100       100000      8.3e-15     4.7e-16
    158            IEEE     1,10000     100000      2.1e-11     1.4e-13
    159          For p between 10^-6 and 10^-3:
    160            IEEE     1,100        50000      1.3e-12     8.4e-15
    161            IEEE     1,10000      50000      3.0e-12     4.8e-14
     149                 a,b                     Relative error:
     150    arithmetic  domain     # trials      peak         rms
     151     For p between .001 and 1:
     152       IEEE     1,100       100000      8.3e-15     4.7e-16
     153       IEEE     1,10000     100000      2.1e-11     1.4e-13
     154     For p between 10^-6 and 10^-3:
     155       IEEE     1,100        50000      1.3e-12     8.4e-15
     156       IEEE     1,10000      50000      3.0e-12     4.8e-14
    162157
    163         Cephes Math Library Release 2.8:  June, 2000
    164         Copyright 1984, 1987, 1995, 2000 by Stephen L. Moshier
    165         *************************************************************************/
    166         public static double invfdistribution(int a,
    167             int b,
    168             double y)
    169         {
    170             double result = 0;
    171             double w = 0;
     158    Cephes Math Library Release 2.8:  June, 2000
     159    Copyright 1984, 1987, 1995, 2000 by Stephen L. Moshier
     160    *************************************************************************/
     161    public static double invfdistribution(int a,
     162        int b,
     163        double y) {
     164      double result = 0;
     165      double w = 0;
    172166
    173             System.Diagnostics.Debug.Assert(a>=1 & b>=1 & (double)(y)>(double)(0) & (double)(y)<=(double)(1), "Domain error in InvFDistribution");
    174            
    175             //
    176             // Compute probability for x = 0.5
    177             //
    178             w = ibetaf.incompletebeta(0.5*b, 0.5*a, 0.5);
    179            
    180             //
    181             // If that is greater than y, then the solution w < .5
    182             // Otherwise, solve at 1-y to remove cancellation in (b - b*w)
    183             //
    184             if( (double)(w)>(double)(y) | (double)(y)<(double)(0.001) )
    185             {
    186                 w = ibetaf.invincompletebeta(0.5*b, 0.5*a, y);
    187                 result = (b-b*w)/(a*w);
    188             }
    189             else
    190             {
    191                 w = ibetaf.invincompletebeta(0.5*a, 0.5*b, 1.0-y);
    192                 result = b*w/(a*(1.0-w));
    193             }
    194             return result;
    195         }
     167      System.Diagnostics.Debug.Assert(a >= 1 & b >= 1 & (double)(y) > (double)(0) & (double)(y) <= (double)(1), "Domain error in InvFDistribution");
     168
     169      //
     170      // Compute probability for x = 0.5
     171      //
     172      w = ibetaf.incompletebeta(0.5 * b, 0.5 * a, 0.5);
     173
     174      //
     175      // If that is greater than y, then the solution w < .5
     176      // Otherwise, solve at 1-y to remove cancellation in (b - b*w)
     177      //
     178      if ((double)(w) > (double)(y) | (double)(y) < (double)(0.001)) {
     179        w = ibetaf.invincompletebeta(0.5 * b, 0.5 * a, y);
     180        result = (b - b * w) / (a * w);
     181      } else {
     182        w = ibetaf.invincompletebeta(0.5 * a, 0.5 * b, 1.0 - y);
     183        result = b * w / (a * (1.0 - w));
     184      }
     185      return result;
    196186    }
     187  }
    197188}
Note: See TracChangeset for help on using the changeset viewer.