[2563] | 1 | /*************************************************************************
|
---|
| 2 | Copyright (c) 2007, Sergey Bochkanov (ALGLIB project).
|
---|
| 3 |
|
---|
| 4 | >>> SOURCE LICENSE >>>
|
---|
| 5 | This program is free software; you can redistribute it and/or modify
|
---|
| 6 | it under the terms of the GNU General Public License as published by
|
---|
| 7 | the Free Software Foundation (www.fsf.org); either version 2 of the
|
---|
| 8 | License, or (at your option) any later version.
|
---|
| 9 |
|
---|
| 10 | This program is distributed in the hope that it will be useful,
|
---|
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 13 | GNU General Public License for more details.
|
---|
| 14 |
|
---|
| 15 | A copy of the GNU General Public License is available at
|
---|
| 16 | http://www.fsf.org/licensing/licenses
|
---|
| 17 |
|
---|
| 18 | >>> END OF LICENSE >>>
|
---|
| 19 | *************************************************************************/
|
---|
| 20 |
|
---|
| 21 | using System;
|
---|
| 22 |
|
---|
| 23 | namespace alglib
|
---|
| 24 | {
|
---|
| 25 | public class correlationtests
|
---|
| 26 | {
|
---|
| 27 | /*************************************************************************
|
---|
| 28 | Pearson's correlation coefficient significance test
|
---|
| 29 |
|
---|
| 30 | This test checks hypotheses about whether X and Y are samples of two
|
---|
| 31 | continuous distributions having zero correlation or whether their
|
---|
| 32 | correlation is non-zero.
|
---|
| 33 |
|
---|
| 34 | The following tests are performed:
|
---|
| 35 | * two-tailed test (null hypothesis - X and Y have zero correlation)
|
---|
| 36 | * left-tailed test (null hypothesis - the correlation coefficient is
|
---|
| 37 | greater than or equal to 0)
|
---|
| 38 | * right-tailed test (null hypothesis - the correlation coefficient is
|
---|
| 39 | less than or equal to 0).
|
---|
| 40 |
|
---|
| 41 | Requirements:
|
---|
| 42 | * the number of elements in each sample is not less than 5
|
---|
| 43 | * normality of distributions of X and Y.
|
---|
| 44 |
|
---|
| 45 | Input parameters:
|
---|
| 46 | R - Pearson's correlation coefficient for X and Y
|
---|
| 47 | N - number of elements in samples, N>=5.
|
---|
| 48 |
|
---|
| 49 | Output parameters:
|
---|
| 50 | BothTails - p-value for two-tailed test.
|
---|
| 51 | If BothTails is less than the given significance level
|
---|
| 52 | the null hypothesis is rejected.
|
---|
| 53 | LeftTail - p-value for left-tailed test.
|
---|
| 54 | If LeftTail is less than the given significance level,
|
---|
| 55 | the null hypothesis is rejected.
|
---|
| 56 | RightTail - p-value for right-tailed test.
|
---|
| 57 | If RightTail is less than the given significance level
|
---|
| 58 | the null hypothesis is rejected.
|
---|
| 59 |
|
---|
| 60 | -- ALGLIB --
|
---|
| 61 | Copyright 09.04.2007 by Bochkanov Sergey
|
---|
| 62 | *************************************************************************/
|
---|
| 63 | public static void pearsoncorrelationsignificance(double r,
|
---|
| 64 | int n,
|
---|
| 65 | ref double bothtails,
|
---|
| 66 | ref double lefttail,
|
---|
| 67 | ref double righttail)
|
---|
| 68 | {
|
---|
| 69 | double t = 0;
|
---|
| 70 | double p = 0;
|
---|
| 71 |
|
---|
| 72 |
|
---|
| 73 | //
|
---|
| 74 | // Some special cases
|
---|
| 75 | //
|
---|
| 76 | if( (double)(r)>=(double)(1) )
|
---|
| 77 | {
|
---|
| 78 | bothtails = 0.0;
|
---|
| 79 | lefttail = 1.0;
|
---|
| 80 | righttail = 0.0;
|
---|
| 81 | return;
|
---|
| 82 | }
|
---|
| 83 | if( (double)(r)<=(double)(-1) )
|
---|
| 84 | {
|
---|
| 85 | bothtails = 0.0;
|
---|
| 86 | lefttail = 0.0;
|
---|
| 87 | righttail = 1.0;
|
---|
| 88 | return;
|
---|
| 89 | }
|
---|
| 90 | if( n<5 )
|
---|
| 91 | {
|
---|
| 92 | bothtails = 1.0;
|
---|
| 93 | lefttail = 1.0;
|
---|
| 94 | righttail = 1.0;
|
---|
| 95 | return;
|
---|
| 96 | }
|
---|
| 97 |
|
---|
| 98 | //
|
---|
| 99 | // General case
|
---|
| 100 | //
|
---|
| 101 | t = r*Math.Sqrt((n-2)/(1-AP.Math.Sqr(r)));
|
---|
| 102 | p = studenttdistr.studenttdistribution(n-2, t);
|
---|
| 103 | bothtails = 2*Math.Min(p, 1-p);
|
---|
| 104 | lefttail = p;
|
---|
| 105 | righttail = 1-p;
|
---|
| 106 | }
|
---|
| 107 |
|
---|
| 108 |
|
---|
| 109 | /*************************************************************************
|
---|
| 110 | Spearman's rank correlation coefficient significance test
|
---|
| 111 |
|
---|
| 112 | This test checks hypotheses about whether X and Y are samples of two
|
---|
| 113 | continuous distributions having zero correlation or whether their
|
---|
| 114 | correlation is non-zero.
|
---|
| 115 |
|
---|
| 116 | The following tests are performed:
|
---|
| 117 | * two-tailed test (null hypothesis - X and Y have zero correlation)
|
---|
| 118 | * left-tailed test (null hypothesis - the correlation coefficient is
|
---|
| 119 | greater than or equal to 0)
|
---|
| 120 | * right-tailed test (null hypothesis - the correlation coefficient is
|
---|
| 121 | less than or equal to 0).
|
---|
| 122 |
|
---|
| 123 | Requirements:
|
---|
| 124 | * the number of elements in each sample is not less than 5.
|
---|
| 125 |
|
---|
| 126 | The test is non-parametric and doesn't require distributions X and Y to be
|
---|
| 127 | normal.
|
---|
| 128 |
|
---|
| 129 | Input parameters:
|
---|
| 130 | R - Spearman's rank correlation coefficient for X and Y
|
---|
| 131 | N - number of elements in samples, N>=5.
|
---|
| 132 |
|
---|
| 133 | Output parameters:
|
---|
| 134 | BothTails - p-value for two-tailed test.
|
---|
| 135 | If BothTails is less than the given significance level
|
---|
| 136 | the null hypothesis is rejected.
|
---|
| 137 | LeftTail - p-value for left-tailed test.
|
---|
| 138 | If LeftTail is less than the given significance level,
|
---|
| 139 | the null hypothesis is rejected.
|
---|
| 140 | RightTail - p-value for right-tailed test.
|
---|
| 141 | If RightTail is less than the given significance level
|
---|
| 142 | the null hypothesis is rejected.
|
---|
| 143 |
|
---|
| 144 | -- ALGLIB --
|
---|
| 145 | Copyright 09.04.2007 by Bochkanov Sergey
|
---|
| 146 | *************************************************************************/
|
---|
| 147 | public static void spearmanrankcorrelationsignificance(double r,
|
---|
| 148 | int n,
|
---|
| 149 | ref double bothtails,
|
---|
| 150 | ref double lefttail,
|
---|
| 151 | ref double righttail)
|
---|
| 152 | {
|
---|
| 153 | double t = 0;
|
---|
| 154 | double p = 0;
|
---|
| 155 |
|
---|
| 156 |
|
---|
| 157 | //
|
---|
| 158 | // Special case
|
---|
| 159 | //
|
---|
| 160 | if( n<5 )
|
---|
| 161 | {
|
---|
| 162 | bothtails = 1.0;
|
---|
| 163 | lefttail = 1.0;
|
---|
| 164 | righttail = 1.0;
|
---|
| 165 | return;
|
---|
| 166 | }
|
---|
| 167 |
|
---|
| 168 | //
|
---|
| 169 | // General case
|
---|
| 170 | //
|
---|
| 171 | if( (double)(r)>=(double)(1) )
|
---|
| 172 | {
|
---|
| 173 | t = 1.0E10;
|
---|
| 174 | }
|
---|
| 175 | else
|
---|
| 176 | {
|
---|
| 177 | if( (double)(r)<=(double)(-1) )
|
---|
| 178 | {
|
---|
| 179 | t = -1.0E10;
|
---|
| 180 | }
|
---|
| 181 | else
|
---|
| 182 | {
|
---|
| 183 | t = r*Math.Sqrt((n-2)/(1-AP.Math.Sqr(r)));
|
---|
| 184 | }
|
---|
| 185 | }
|
---|
| 186 | if( (double)(t)<(double)(0) )
|
---|
| 187 | {
|
---|
| 188 | p = spearmantail(t, n);
|
---|
| 189 | bothtails = 2*p;
|
---|
| 190 | lefttail = p;
|
---|
| 191 | righttail = 1-p;
|
---|
| 192 | }
|
---|
| 193 | else
|
---|
| 194 | {
|
---|
| 195 | p = spearmantail(-t, n);
|
---|
| 196 | bothtails = 2*p;
|
---|
| 197 | lefttail = 1-p;
|
---|
| 198 | righttail = p;
|
---|
| 199 | }
|
---|
| 200 | }
|
---|
| 201 |
|
---|
| 202 |
|
---|
| 203 | /*************************************************************************
|
---|
| 204 | Tail(S, 5)
|
---|
| 205 | *************************************************************************/
|
---|
| 206 | private static double spearmantail5(double s)
|
---|
| 207 | {
|
---|
| 208 | double result = 0;
|
---|
| 209 |
|
---|
| 210 | if( (double)(s)<(double)(0.000e+00) )
|
---|
| 211 | {
|
---|
| 212 | result = studenttdistr.studenttdistribution(3, -s);
|
---|
| 213 | return result;
|
---|
| 214 | }
|
---|
| 215 | if( (double)(s)>=(double)(3.580e+00) )
|
---|
| 216 | {
|
---|
| 217 | result = 8.304e-03;
|
---|
| 218 | return result;
|
---|
| 219 | }
|
---|
| 220 | if( (double)(s)>=(double)(2.322e+00) )
|
---|
| 221 | {
|
---|
| 222 | result = 4.163e-02;
|
---|
| 223 | return result;
|
---|
| 224 | }
|
---|
| 225 | if( (double)(s)>=(double)(1.704e+00) )
|
---|
| 226 | {
|
---|
| 227 | result = 6.641e-02;
|
---|
| 228 | return result;
|
---|
| 229 | }
|
---|
| 230 | if( (double)(s)>=(double)(1.303e+00) )
|
---|
| 231 | {
|
---|
| 232 | result = 1.164e-01;
|
---|
| 233 | return result;
|
---|
| 234 | }
|
---|
| 235 | if( (double)(s)>=(double)(1.003e+00) )
|
---|
| 236 | {
|
---|
| 237 | result = 1.748e-01;
|
---|
| 238 | return result;
|
---|
| 239 | }
|
---|
| 240 | if( (double)(s)>=(double)(7.584e-01) )
|
---|
| 241 | {
|
---|
| 242 | result = 2.249e-01;
|
---|
| 243 | return result;
|
---|
| 244 | }
|
---|
| 245 | if( (double)(s)>=(double)(5.468e-01) )
|
---|
| 246 | {
|
---|
| 247 | result = 2.581e-01;
|
---|
| 248 | return result;
|
---|
| 249 | }
|
---|
| 250 | if( (double)(s)>=(double)(3.555e-01) )
|
---|
| 251 | {
|
---|
| 252 | result = 3.413e-01;
|
---|
| 253 | return result;
|
---|
| 254 | }
|
---|
| 255 | if( (double)(s)>=(double)(1.759e-01) )
|
---|
| 256 | {
|
---|
| 257 | result = 3.911e-01;
|
---|
| 258 | return result;
|
---|
| 259 | }
|
---|
| 260 | if( (double)(s)>=(double)(1.741e-03) )
|
---|
| 261 | {
|
---|
| 262 | result = 4.747e-01;
|
---|
| 263 | return result;
|
---|
| 264 | }
|
---|
| 265 | if( (double)(s)>=(double)(0.000e+00) )
|
---|
| 266 | {
|
---|
| 267 | result = 5.248e-01;
|
---|
| 268 | return result;
|
---|
| 269 | }
|
---|
| 270 | result = 0;
|
---|
| 271 | return result;
|
---|
| 272 | }
|
---|
| 273 |
|
---|
| 274 |
|
---|
| 275 | /*************************************************************************
|
---|
| 276 | Tail(S, 6)
|
---|
| 277 | *************************************************************************/
|
---|
| 278 | private static double spearmantail6(double s)
|
---|
| 279 | {
|
---|
| 280 | double result = 0;
|
---|
| 281 |
|
---|
| 282 | if( (double)(s)<(double)(1.001e+00) )
|
---|
| 283 | {
|
---|
| 284 | result = studenttdistr.studenttdistribution(4, -s);
|
---|
| 285 | return result;
|
---|
| 286 | }
|
---|
| 287 | if( (double)(s)>=(double)(5.663e+00) )
|
---|
| 288 | {
|
---|
| 289 | result = 1.366e-03;
|
---|
| 290 | return result;
|
---|
| 291 | }
|
---|
| 292 | if( (double)(s)>=(double)(3.834e+00) )
|
---|
| 293 | {
|
---|
| 294 | result = 8.350e-03;
|
---|
| 295 | return result;
|
---|
| 296 | }
|
---|
| 297 | if( (double)(s)>=(double)(2.968e+00) )
|
---|
| 298 | {
|
---|
| 299 | result = 1.668e-02;
|
---|
| 300 | return result;
|
---|
| 301 | }
|
---|
| 302 | if( (double)(s)>=(double)(2.430e+00) )
|
---|
| 303 | {
|
---|
| 304 | result = 2.921e-02;
|
---|
| 305 | return result;
|
---|
| 306 | }
|
---|
| 307 | if( (double)(s)>=(double)(2.045e+00) )
|
---|
| 308 | {
|
---|
| 309 | result = 5.144e-02;
|
---|
| 310 | return result;
|
---|
| 311 | }
|
---|
| 312 | if( (double)(s)>=(double)(1.747e+00) )
|
---|
| 313 | {
|
---|
| 314 | result = 6.797e-02;
|
---|
| 315 | return result;
|
---|
| 316 | }
|
---|
| 317 | if( (double)(s)>=(double)(1.502e+00) )
|
---|
| 318 | {
|
---|
| 319 | result = 8.752e-02;
|
---|
| 320 | return result;
|
---|
| 321 | }
|
---|
| 322 | if( (double)(s)>=(double)(1.295e+00) )
|
---|
| 323 | {
|
---|
| 324 | result = 1.210e-01;
|
---|
| 325 | return result;
|
---|
| 326 | }
|
---|
| 327 | if( (double)(s)>=(double)(1.113e+00) )
|
---|
| 328 | {
|
---|
| 329 | result = 1.487e-01;
|
---|
| 330 | return result;
|
---|
| 331 | }
|
---|
| 332 | if( (double)(s)>=(double)(1.001e+00) )
|
---|
| 333 | {
|
---|
| 334 | result = 1.780e-01;
|
---|
| 335 | return result;
|
---|
| 336 | }
|
---|
| 337 | result = 0;
|
---|
| 338 | return result;
|
---|
| 339 | }
|
---|
| 340 |
|
---|
| 341 |
|
---|
| 342 | /*************************************************************************
|
---|
| 343 | Tail(S, 7)
|
---|
| 344 | *************************************************************************/
|
---|
| 345 | private static double spearmantail7(double s)
|
---|
| 346 | {
|
---|
| 347 | double result = 0;
|
---|
| 348 |
|
---|
| 349 | if( (double)(s)<(double)(1.001e+00) )
|
---|
| 350 | {
|
---|
| 351 | result = studenttdistr.studenttdistribution(5, -s);
|
---|
| 352 | return result;
|
---|
| 353 | }
|
---|
| 354 | if( (double)(s)>=(double)(8.159e+00) )
|
---|
| 355 | {
|
---|
| 356 | result = 2.081e-04;
|
---|
| 357 | return result;
|
---|
| 358 | }
|
---|
| 359 | if( (double)(s)>=(double)(5.620e+00) )
|
---|
| 360 | {
|
---|
| 361 | result = 1.393e-03;
|
---|
| 362 | return result;
|
---|
| 363 | }
|
---|
| 364 | if( (double)(s)>=(double)(4.445e+00) )
|
---|
| 365 | {
|
---|
| 366 | result = 3.398e-03;
|
---|
| 367 | return result;
|
---|
| 368 | }
|
---|
| 369 | if( (double)(s)>=(double)(3.728e+00) )
|
---|
| 370 | {
|
---|
| 371 | result = 6.187e-03;
|
---|
| 372 | return result;
|
---|
| 373 | }
|
---|
| 374 | if( (double)(s)>=(double)(3.226e+00) )
|
---|
| 375 | {
|
---|
| 376 | result = 1.200e-02;
|
---|
| 377 | return result;
|
---|
| 378 | }
|
---|
| 379 | if( (double)(s)>=(double)(2.844e+00) )
|
---|
| 380 | {
|
---|
| 381 | result = 1.712e-02;
|
---|
| 382 | return result;
|
---|
| 383 | }
|
---|
| 384 | if( (double)(s)>=(double)(2.539e+00) )
|
---|
| 385 | {
|
---|
| 386 | result = 2.408e-02;
|
---|
| 387 | return result;
|
---|
| 388 | }
|
---|
| 389 | if( (double)(s)>=(double)(2.285e+00) )
|
---|
| 390 | {
|
---|
| 391 | result = 3.320e-02;
|
---|
| 392 | return result;
|
---|
| 393 | }
|
---|
| 394 | if( (double)(s)>=(double)(2.068e+00) )
|
---|
| 395 | {
|
---|
| 396 | result = 4.406e-02;
|
---|
| 397 | return result;
|
---|
| 398 | }
|
---|
| 399 | if( (double)(s)>=(double)(1.879e+00) )
|
---|
| 400 | {
|
---|
| 401 | result = 5.478e-02;
|
---|
| 402 | return result;
|
---|
| 403 | }
|
---|
| 404 | if( (double)(s)>=(double)(1.710e+00) )
|
---|
| 405 | {
|
---|
| 406 | result = 6.946e-02;
|
---|
| 407 | return result;
|
---|
| 408 | }
|
---|
| 409 | if( (double)(s)>=(double)(1.559e+00) )
|
---|
| 410 | {
|
---|
| 411 | result = 8.331e-02;
|
---|
| 412 | return result;
|
---|
| 413 | }
|
---|
| 414 | if( (double)(s)>=(double)(1.420e+00) )
|
---|
| 415 | {
|
---|
| 416 | result = 1.001e-01;
|
---|
| 417 | return result;
|
---|
| 418 | }
|
---|
| 419 | if( (double)(s)>=(double)(1.292e+00) )
|
---|
| 420 | {
|
---|
| 421 | result = 1.180e-01;
|
---|
| 422 | return result;
|
---|
| 423 | }
|
---|
| 424 | if( (double)(s)>=(double)(1.173e+00) )
|
---|
| 425 | {
|
---|
| 426 | result = 1.335e-01;
|
---|
| 427 | return result;
|
---|
| 428 | }
|
---|
| 429 | if( (double)(s)>=(double)(1.062e+00) )
|
---|
| 430 | {
|
---|
| 431 | result = 1.513e-01;
|
---|
| 432 | return result;
|
---|
| 433 | }
|
---|
| 434 | if( (double)(s)>=(double)(1.001e+00) )
|
---|
| 435 | {
|
---|
| 436 | result = 1.770e-01;
|
---|
| 437 | return result;
|
---|
| 438 | }
|
---|
| 439 | result = 0;
|
---|
| 440 | return result;
|
---|
| 441 | }
|
---|
| 442 |
|
---|
| 443 |
|
---|
| 444 | /*************************************************************************
|
---|
| 445 | Tail(S, 8)
|
---|
| 446 | *************************************************************************/
|
---|
| 447 | private static double spearmantail8(double s)
|
---|
| 448 | {
|
---|
| 449 | double result = 0;
|
---|
| 450 |
|
---|
| 451 | if( (double)(s)<(double)(2.001e+00) )
|
---|
| 452 | {
|
---|
| 453 | result = studenttdistr.studenttdistribution(6, -s);
|
---|
| 454 | return result;
|
---|
| 455 | }
|
---|
| 456 | if( (double)(s)>=(double)(1.103e+01) )
|
---|
| 457 | {
|
---|
| 458 | result = 2.194e-05;
|
---|
| 459 | return result;
|
---|
| 460 | }
|
---|
| 461 | if( (double)(s)>=(double)(7.685e+00) )
|
---|
| 462 | {
|
---|
| 463 | result = 2.008e-04;
|
---|
| 464 | return result;
|
---|
| 465 | }
|
---|
| 466 | if( (double)(s)>=(double)(6.143e+00) )
|
---|
| 467 | {
|
---|
| 468 | result = 5.686e-04;
|
---|
| 469 | return result;
|
---|
| 470 | }
|
---|
| 471 | if( (double)(s)>=(double)(5.213e+00) )
|
---|
| 472 | {
|
---|
| 473 | result = 1.138e-03;
|
---|
| 474 | return result;
|
---|
| 475 | }
|
---|
| 476 | if( (double)(s)>=(double)(4.567e+00) )
|
---|
| 477 | {
|
---|
| 478 | result = 2.310e-03;
|
---|
| 479 | return result;
|
---|
| 480 | }
|
---|
| 481 | if( (double)(s)>=(double)(4.081e+00) )
|
---|
| 482 | {
|
---|
| 483 | result = 3.634e-03;
|
---|
| 484 | return result;
|
---|
| 485 | }
|
---|
| 486 | if( (double)(s)>=(double)(3.697e+00) )
|
---|
| 487 | {
|
---|
| 488 | result = 5.369e-03;
|
---|
| 489 | return result;
|
---|
| 490 | }
|
---|
| 491 | if( (double)(s)>=(double)(3.381e+00) )
|
---|
| 492 | {
|
---|
| 493 | result = 7.708e-03;
|
---|
| 494 | return result;
|
---|
| 495 | }
|
---|
| 496 | if( (double)(s)>=(double)(3.114e+00) )
|
---|
| 497 | {
|
---|
| 498 | result = 1.087e-02;
|
---|
| 499 | return result;
|
---|
| 500 | }
|
---|
| 501 | if( (double)(s)>=(double)(2.884e+00) )
|
---|
| 502 | {
|
---|
| 503 | result = 1.397e-02;
|
---|
| 504 | return result;
|
---|
| 505 | }
|
---|
| 506 | if( (double)(s)>=(double)(2.682e+00) )
|
---|
| 507 | {
|
---|
| 508 | result = 1.838e-02;
|
---|
| 509 | return result;
|
---|
| 510 | }
|
---|
| 511 | if( (double)(s)>=(double)(2.502e+00) )
|
---|
| 512 | {
|
---|
| 513 | result = 2.288e-02;
|
---|
| 514 | return result;
|
---|
| 515 | }
|
---|
| 516 | if( (double)(s)>=(double)(2.340e+00) )
|
---|
| 517 | {
|
---|
| 518 | result = 2.883e-02;
|
---|
| 519 | return result;
|
---|
| 520 | }
|
---|
| 521 | if( (double)(s)>=(double)(2.192e+00) )
|
---|
| 522 | {
|
---|
| 523 | result = 3.469e-02;
|
---|
| 524 | return result;
|
---|
| 525 | }
|
---|
| 526 | if( (double)(s)>=(double)(2.057e+00) )
|
---|
| 527 | {
|
---|
| 528 | result = 4.144e-02;
|
---|
| 529 | return result;
|
---|
| 530 | }
|
---|
| 531 | if( (double)(s)>=(double)(2.001e+00) )
|
---|
| 532 | {
|
---|
| 533 | result = 4.804e-02;
|
---|
| 534 | return result;
|
---|
| 535 | }
|
---|
| 536 | result = 0;
|
---|
| 537 | return result;
|
---|
| 538 | }
|
---|
| 539 |
|
---|
| 540 |
|
---|
| 541 | /*************************************************************************
|
---|
| 542 | Tail(S, 9)
|
---|
| 543 | *************************************************************************/
|
---|
| 544 | private static double spearmantail9(double s)
|
---|
| 545 | {
|
---|
| 546 | double result = 0;
|
---|
| 547 |
|
---|
| 548 | if( (double)(s)<(double)(2.001e+00) )
|
---|
| 549 | {
|
---|
| 550 | result = studenttdistr.studenttdistribution(7, -s);
|
---|
| 551 | return result;
|
---|
| 552 | }
|
---|
| 553 | if( (double)(s)>=(double)(9.989e+00) )
|
---|
| 554 | {
|
---|
| 555 | result = 2.306e-05;
|
---|
| 556 | return result;
|
---|
| 557 | }
|
---|
| 558 | if( (double)(s)>=(double)(8.069e+00) )
|
---|
| 559 | {
|
---|
| 560 | result = 8.167e-05;
|
---|
| 561 | return result;
|
---|
| 562 | }
|
---|
| 563 | if( (double)(s)>=(double)(6.890e+00) )
|
---|
| 564 | {
|
---|
| 565 | result = 1.744e-04;
|
---|
| 566 | return result;
|
---|
| 567 | }
|
---|
| 568 | if( (double)(s)>=(double)(6.077e+00) )
|
---|
| 569 | {
|
---|
| 570 | result = 3.625e-04;
|
---|
| 571 | return result;
|
---|
| 572 | }
|
---|
| 573 | if( (double)(s)>=(double)(5.469e+00) )
|
---|
| 574 | {
|
---|
| 575 | result = 6.450e-04;
|
---|
| 576 | return result;
|
---|
| 577 | }
|
---|
| 578 | if( (double)(s)>=(double)(4.991e+00) )
|
---|
| 579 | {
|
---|
| 580 | result = 1.001e-03;
|
---|
| 581 | return result;
|
---|
| 582 | }
|
---|
| 583 | if( (double)(s)>=(double)(4.600e+00) )
|
---|
| 584 | {
|
---|
| 585 | result = 1.514e-03;
|
---|
| 586 | return result;
|
---|
| 587 | }
|
---|
| 588 | if( (double)(s)>=(double)(4.272e+00) )
|
---|
| 589 | {
|
---|
| 590 | result = 2.213e-03;
|
---|
| 591 | return result;
|
---|
| 592 | }
|
---|
| 593 | if( (double)(s)>=(double)(3.991e+00) )
|
---|
| 594 | {
|
---|
| 595 | result = 2.990e-03;
|
---|
| 596 | return result;
|
---|
| 597 | }
|
---|
| 598 | if( (double)(s)>=(double)(3.746e+00) )
|
---|
| 599 | {
|
---|
| 600 | result = 4.101e-03;
|
---|
| 601 | return result;
|
---|
| 602 | }
|
---|
| 603 | if( (double)(s)>=(double)(3.530e+00) )
|
---|
| 604 | {
|
---|
| 605 | result = 5.355e-03;
|
---|
| 606 | return result;
|
---|
| 607 | }
|
---|
| 608 | if( (double)(s)>=(double)(3.336e+00) )
|
---|
| 609 | {
|
---|
| 610 | result = 6.887e-03;
|
---|
| 611 | return result;
|
---|
| 612 | }
|
---|
| 613 | if( (double)(s)>=(double)(3.161e+00) )
|
---|
| 614 | {
|
---|
| 615 | result = 8.598e-03;
|
---|
| 616 | return result;
|
---|
| 617 | }
|
---|
| 618 | if( (double)(s)>=(double)(3.002e+00) )
|
---|
| 619 | {
|
---|
| 620 | result = 1.065e-02;
|
---|
| 621 | return result;
|
---|
| 622 | }
|
---|
| 623 | if( (double)(s)>=(double)(2.855e+00) )
|
---|
| 624 | {
|
---|
| 625 | result = 1.268e-02;
|
---|
| 626 | return result;
|
---|
| 627 | }
|
---|
| 628 | if( (double)(s)>=(double)(2.720e+00) )
|
---|
| 629 | {
|
---|
| 630 | result = 1.552e-02;
|
---|
| 631 | return result;
|
---|
| 632 | }
|
---|
| 633 | if( (double)(s)>=(double)(2.595e+00) )
|
---|
| 634 | {
|
---|
| 635 | result = 1.836e-02;
|
---|
| 636 | return result;
|
---|
| 637 | }
|
---|
| 638 | if( (double)(s)>=(double)(2.477e+00) )
|
---|
| 639 | {
|
---|
| 640 | result = 2.158e-02;
|
---|
| 641 | return result;
|
---|
| 642 | }
|
---|
| 643 | if( (double)(s)>=(double)(2.368e+00) )
|
---|
| 644 | {
|
---|
| 645 | result = 2.512e-02;
|
---|
| 646 | return result;
|
---|
| 647 | }
|
---|
| 648 | if( (double)(s)>=(double)(2.264e+00) )
|
---|
| 649 | {
|
---|
| 650 | result = 2.942e-02;
|
---|
| 651 | return result;
|
---|
| 652 | }
|
---|
| 653 | if( (double)(s)>=(double)(2.166e+00) )
|
---|
| 654 | {
|
---|
| 655 | result = 3.325e-02;
|
---|
| 656 | return result;
|
---|
| 657 | }
|
---|
| 658 | if( (double)(s)>=(double)(2.073e+00) )
|
---|
| 659 | {
|
---|
| 660 | result = 3.800e-02;
|
---|
| 661 | return result;
|
---|
| 662 | }
|
---|
| 663 | if( (double)(s)>=(double)(2.001e+00) )
|
---|
| 664 | {
|
---|
| 665 | result = 4.285e-02;
|
---|
| 666 | return result;
|
---|
| 667 | }
|
---|
| 668 | result = 0;
|
---|
| 669 | return result;
|
---|
| 670 | }
|
---|
| 671 |
|
---|
| 672 |
|
---|
| 673 | /*************************************************************************
|
---|
| 674 | Tail(T,N), accepts T<0
|
---|
| 675 | *************************************************************************/
|
---|
| 676 | private static double spearmantail(double t,
|
---|
| 677 | int n)
|
---|
| 678 | {
|
---|
| 679 | double result = 0;
|
---|
| 680 |
|
---|
| 681 | if( n==5 )
|
---|
| 682 | {
|
---|
| 683 | result = spearmantail5(-t);
|
---|
| 684 | return result;
|
---|
| 685 | }
|
---|
| 686 | if( n==6 )
|
---|
| 687 | {
|
---|
| 688 | result = spearmantail6(-t);
|
---|
| 689 | return result;
|
---|
| 690 | }
|
---|
| 691 | if( n==7 )
|
---|
| 692 | {
|
---|
| 693 | result = spearmantail7(-t);
|
---|
| 694 | return result;
|
---|
| 695 | }
|
---|
| 696 | if( n==8 )
|
---|
| 697 | {
|
---|
| 698 | result = spearmantail8(-t);
|
---|
| 699 | return result;
|
---|
| 700 | }
|
---|
| 701 | if( n==9 )
|
---|
| 702 | {
|
---|
| 703 | result = spearmantail9(-t);
|
---|
| 704 | return result;
|
---|
| 705 | }
|
---|
| 706 | result = studenttdistr.studenttdistribution(n-2, t);
|
---|
| 707 | return result;
|
---|
| 708 | }
|
---|
| 709 | }
|
---|
| 710 | }
|
---|