| Literature DB >> 29765345 |
Carmen Moret-Tatay1, Daniel Gamermann2, Esperanza Navarro-Pardo3, Pedro Fernández de Córdoba Castellá4.
Abstract
The study of reaction times and their underlying cognitive processes is an important field in Psychology. Reaction times are often modeled through the ex-Gaussian distribution, because it provides a good fit to multiple empirical data. The complexity of this distribution makes the use of computational tools an essential element. Therefore, there is a strong need for efficient and versatile computational tools for the research in this area. In this manuscript we discuss some mathematical details of the ex-Gaussian distribution and apply the ExGUtils package, a set of functions and numerical tools, programmed for python, developed for numerical analysis of data involving the ex-Gaussian probability density. In order to validate the package, we present an extensive analysis of fits obtained with it, discuss advantages and differences between the least squares and maximum likelihood methods and quantitatively evaluate the goodness of the obtained fits (which is usually an overlooked point in most literature in the area). The analysis done allows one to identify outliers in the empirical datasets and criteriously determine if there is a need for data trimming and at which points it should be done.Entities:
Keywords: ex-Gaussian fit; python; response components; response times; significance testing
Year: 2018 PMID: 29765345 PMCID: PMC5939052 DOI: 10.3389/fpsyg.2018.00612
Source DB: PubMed Journal: Front Psychol ISSN: 1664-1078
Figure 1ex-Gaussian distributions for different values of the λ asymmetry parameter.
Figure 2Differences between the ex-Gaussian distribution with λ = 0.2 and the gaussian distribution. Both curves plotted on the left and the difference on the right (note this difference is less than 1%).
Functions present in the package modules.
| Present | drand | Returns a random number with homogeneous distribution between 0 and 1 |
| in | exp_rvs | Returns a random number with exponential distribution between 0 and infinity |
| both | gauss_rvs | Returns a random number with gaussian distribution between minus infinity and infinity |
| modules | exg_rvs | Returns a random number with ex-Gaussian distribution between minus infinity and infinity |
| gauss_pdf | Evaluates the gaussian distribution at a given point | |
| gauss_cdf | Evaluates the gaussian cumulative distribution at a given point | |
| exg_pdf | Evaluates the ex-Gaussian distribution at a given point | |
| exg_cdf | Evaluates the ex-Gaussian cumulative distribution at a given point | |
| exg_lamb_pdf | Evaluates the ex-Gaussian distribution parameterized in terms of its asymmetry at a given point | |
| exg_lamb_cdf | Evaluates the ex-Gaussian cumulative distribution parameterized in terms of its asymmetry at a given point | |
| pars_to_stats | Given the parameters μ, σ and τ, evaluates the corresponding statistics | |
| stats_to_pars | Given the statistics | |
| histogram | Given a set of observations, produces an histogram | |
| stats | Given a set of observations, returns the statistics | |
| stats_his | Given a set of observations, presented as a histogram, returns the statistics | |
| correlation | Given a set of points, returns the linear correlation coefficient for the points | |
| minsquare | Given a set of points, fits a polynomial to the data using the least square method | |
| exgLKHD | Evaluates the likelihood and its gradient in the parameter space for a dataset in a given point of the parameter space | |
| maxLKHD | Evaluates the parameters μ, σ and τ that maximize the likelihood for a given dataset | |
| exgSQR | Evaluates the sum of squared differences and its gradient in the parameter space for an histogram in a given point of the parameter space | |
| minSQR | Evaluates the parameters μ, σ and τ that minimize the sum of squared differences for a given histogram | |
| Only | int_points_gauss | Creates a point partition of an interval for evaluating a |
| in | gaussian integral | |
| intsum | Evaluates the gaussian integral for a function calculated at the points in a gaussian partition | |
| Only | zero | Finds the zero of an equation |
| in | ANOVA | Performs an ANOVA test |
| integral | Evaluates an integral |
In python type .
Parameters and statistics obtained with the three fitting methods.
| elder_gng | 831.14 | 318.95 | 1.75 | 526.06 | 93.02 | 305.08 | 841.45 | 334.97 | 1.85 | 515.16 | 75.76 | 326.29 | 831.14 | 318.39 | 1.79 | 524.49 | 85.67 | 306.65 |
| elder_hfgng | 798.55 | 310.00 | 1.94 | 491.52 | 42.78 | 307.03 | 803.42 | 308.32 | 1.82 | 504.66 | 76.18 | 298.76 | 796.63 | 312.32 | 1.90 | 489.39 | 56.11 | 307.24 |
| elder_hfyn | 826.15 | 278.61 | 1.62 | 566.56 | 101.16 | 259.59 | 810.03 | 256.41 | 1.68 | 568.03 | 84.74 | 242.00 | 826.15 | 275.10 | 1.75 | 563.06 | 80.40 | 263.08 |
| elder_lfgng | 863.73 | 324.53 | 1.60 | 562.65 | 121.14 | 301.08 | 887.69 | 371.88 | 1.90 | 522.22 | 68.76 | 365.46 | 863.73 | 339.88 | 1.87 | 531.43 | 71.38 | 332.30 |
| elder_lfyn | 884.53 | 315.93 | 1.59 | 591.97 | 119.27 | 292.55 | 882.16 | 310.04 | 1.77 | 584.33 | 86.12 | 297.84 | 884.53 | 308.13 | 1.62 | 597.54 | 112.18 | 286.98 |
| elder_pseudo | 1189.64 | 416.92 | 0.88 | 872.59 | 270.73 | 317.05 | 1233.90 | 518.22 | 1.79 | 734.21 | 137.33 | 499.69 | 1189.64 | 447.89 | 1.60 | 773.74 | 166.24 | 415.90 |
| elder_yn | 854.88 | 298.93 | 1.63 | 575.78 | 107.04 | 279.11 | 846.94 | 286.75 | 1.75 | 572.77 | 84.01 | 274.17 | 854.88 | 292.72 | 1.68 | 578.59 | 96.69 | 276.29 |
| young_gng | 597.90 | 169.90 | 2.71 | – | – | – | 590.36 | 142.94 | 1.66 | 455.98 | 48.71 | 134.38 | 597.90 | 154.25 | 1.72 | 451.09 | 47.33 | 146.81 |
| young_hfgng | 562.94 | 141.88 | 3.04 | – | – | – | 555.47 | 115.19 | 1.54 | 449.84 | 45.93 | 105.63 | 562.94 | 126.30 | 1.65 | 444.47 | 43.77 | 118.47 |
| young_hfyn | 621.16 | 176.99 | 3.88 | – | – | – | 610.51 | 128.15 | 1.53 | 493.32 | 51.86 | 117.19 | 621.16 | 148.38 | 1.65 | 482.08 | 51.70 | 139.08 |
| young_lf | 632.96 | 187.61 | 2.46 | – | – | – | 625.36 | 161.43 | 1.65 | 473.80 | 55.61 | 151.55 | 632.96 | 173.23 | 1.71 | 468.51 | 54.43 | 164.45 |
| young_lfgng | 632.96 | 187.61 | 2.46 | – | – | – | 625.36 | 161.43 | 1.65 | 473.80 | 55.61 | 151.55 | 632.96 | 173.23 | 1.71 | 468.51 | 54.43 | 164.45 |
| young_lfyn | 668.57 | 184.88 | 2.10 | – | – | – | 660.23 | 165.16 | 1.60 | 507.06 | 61.77 | 153.18 | 668.58 | 176.56 | 1.70 | 501.24 | 56.31 | 167.34 |
| young_pseudo | 722.53 | 190.36 | 2.37 | – | – | – | 718.60 | 175.25 | 1.64 | 554.66 | 61.92 | 163.94 | 722.53 | 180.58 | 1.68 | 552.03 | 59.47 | 170.50 |
| young_yn | 644.37 | 182.41 | 2.90 | – | – | – | 635.20 | 148.99 | 1.62 | 496.41 | 54.18 | 138.78 | 644.37 | 164.31 | 1.69 | 488.96 | 53.34 | 155.42 |
For each one of the three procedures, we present the obtained parameters and the correspondent statistics. Note that for the method of the moments, the statistics is directly obtained from the dataset and the parameters are evaluated based on this statistic from Equations (18–20), while the other methods obtain the parameters from the dataset and the statistics presented in the table is evaluated based on these parameters from the expressions in eqs. Some conditions were not estimated because of a few atypical measurements far beyond the bulk of the distribution (K larger than 2). (15-17).
Figure 3Data for the young_gng experiment trimmed for outliers with three fitted ex-Gaussians.
Probabilities p1 and p2 for the fits.
| elder_gng | 64.52 | 0.001 (29.47 ± 8.12) | 38.89 | 0.096 (29.96 ± 12.54) |
| elder_hfgng | 44.32 | 0.001 (20.85 ± 5.73) | 49.61 | 0.003 (21.33 ± 5.86) |
| elder_hfyn | 34.10 | 0.019 (20.10 ± 5.35) | 35.30 | 0.021 (20.44 ± 7.49) |
| elder_lfgng | 42.83 | 0.005 (21.73 ± 5.98) | 31.70 | 0.043 (20.96 ± 5.94) |
| elder_lfyn | 17.25 | 0.634 (19.76 ± 5.18) | 29.00 | 0.028 (19.15 ± 5.63) |
| elder_pseudo | 62.79 | 0.000 (26.12 ± 6.81) | 53.10 | 0.009 (25.69 ± 10.41) |
| elder_yn | 32.87 | 0.258 (28.77 ± 7.42) | 62.72 | 0.012 (29.00 ± 14.16) |
| young_gng | 35.92 | 0.136 (28.60 ± 7.39) | 69.38 | 0.003 (28.66 ± 8.36) |
| young_hfgng | 21.33 | 0.305 (19.70 ± 4.99) | 34.11 | 0.016 (20.13 ± 6.16) |
| young_hfyn | 29.75 | 0.049 (19.59 ± 5.04) | 45.20 | 0.009 (19.83 ± 7.03) |
| young_lf | 22.06 | 0.318 (20.39 ± 5.81) | 37.78 | 0.015 (20.67 ± 7.82) |
| young_lfgng | 22.06 | 0.299 (20.08 ± 5.25) | 37.78 | 0.012 (20.27 ± 6.52) |
| young_lfyn | 23.62 | 0.182 (19.66 ± 5.03) | 17.66 | 0.542 (19.56 ± 7.43) |
| young_pseudo | 20.35 | 0.867 (27.86 ± 7.20) | 28.48 | 0.386 (28.44 ± 10.87) |
| young_yn | 38.34 | 0.097 (28.07 ± 7.03) | 54.20 | 0.003 (28.13 ± 8.66) |
KS is the Kolmogorov-Smirnov statistic calculated between the data and its fitted ex-Gaussian. In columns p1 and p2, one finds the probabilities that a randomly generated dataset has a bigger KS statistic than the empirical data. In parenthesis, the average KS statistic and standard deviation for the generated random samples.
Figure 4Fitting results obtained with the minSQR method varying the number of intervals in the histogram for the young_hfgng experiment. The horizontal line shows the value obtained with the maxLKHD method. (Upper left) Evolution of the p probability. (Upper right) Evolution of μ. (Bottom left) Evolution of σ. (Bottom right) Evolution of τ.
The p1 and p2 probabilities for the fits.
| elder_gng | 2,348 | 2 (0.09) | 66.58 | 0.000 (28.92 ± 7.32) | 50.24 | 0.040 (30.98 ± 17.55) |
| elder_hfgng | 1,174 | 8 (0.68) | 34.20 | 0.040 (20.67 ± 5.70) | 32.64 | 0.010 (20.66 ± 5.83) |
| elder_hfyn | 1,175 | 2 (0.17) | 32.09 | 0.040 (20.01 ± 4.86) | 24.76 | 0.090 (19.22 ± 6.69) |
| elder_lfgng | 1,174 | 1 (0.09) | 43.49 | 0.000 (21.47 ± 5.83) | 33.22 | 0.030 (20.57 ± 6.90) |
| elder_lfyn | 1,139 | 4 (0.35) | 19.97 | 0.550 (20.55 ± 6.37) | 19.71 | 0.620 (19.97 ± 6.11) |
| elder_pseudo | 1,910 | 5 (0.26) | 57.26 | 0.000 (26.91 ± 6.64) | 57.11 | 0.010 (26.61 ± 10.06) |
| elder_yn | 2,314 | 5 (0.22) | 36.83 | 0.240 (28.57 ± 7.46) | 29.72 | 0.230 (30.54 ± 14.33) |
| young_gng | 2,396 | 10 (0.42) | 38.93 | 0.250 (27.82 ± 6.32) | 43.11 | 0.020 (30.19 ± 17.07) |
| young_hfgng | 1,200 | 8 (0.67) | 23.28 | 0.780 (19.25 ± 4.39) | 17.82 | 0.430 (18.07 ± 4.13) |
| young_hfyn | 1,180 | 9 (0.76) | 27.97 | 0.050 (19.68 ± 4.91) | 28.93 | 0.010 (20.74 ± 7.71) |
| young_lf | 1,196 | 5 (0.42) | 25.11 | 0.310 (20.09 ± 5.21) | 25.32 | 0.020 (19.69 ± 4.29) |
| young_lfgng | 1,196 | 5 (0.42) | 25.11 | 0.280 (20.51 ± 5.08) | 25.32 | 0.080 (20.55 ± 5.05) |
| young_lfyn | 1,132 | 3 (0.27) | 25.20 | 0.230 (19.42 ± 5.40) | 16.60 | 0.780 (20.72 ± 8.53) |
| young_pseudo | 2,326 | 10 (0.43) | 23.33 | 0.940 (27.59 ± 7.05) | 25.85 | 0.870 (28.45 ± 12.48) |
| young_yn | 2,312 | 12 (0.52) | 46.10 | 0.130 (27.80 ± 7.87) | 28.58 | 0.210 (31.21 ± 19.74) |
KS is the Kolmogorov-Smirnov statistic calculated between the data and its fitted ex-Gaussian. N is the number of data points in each empirical dataset, N′ in the number of points removed by the trimming and in brackets next to it its proportion in relation to the total data. In columns p1 and p2, one finds the probabilities that a randomly generated dataset has a bigger KS statistic than the empirical data. In parenthesis, the average KS statistic and standard deviation for the generated random samples.
Results for different trimming on the data.
| elder_gng | 0.1 | 513.52 | 73.00 | 329.54 | 0.001 | 518.71 | 75.02 | 313.04 | 0.026 |
| elder_gng | 0.5 | 516.62 | 76.61 | 319.50 | 0.002 | 521.83 | 70.31 | 299.00 | 0.011 |
| elder_gng | 1.0 | 516.04 | 76.80 | 317.93 | 0.000 | 523.84 | 66.32 | 291.17 | 0.014 |
| elder_hfgng | 0.1 | 509.10 | 84.96 | 285.05 | 0.043 | 504.96 | 65.26 | 297.06 | 0.012 |
| elder_hfgng | 0.5 | 509.39 | 89.51 | 277.28 | 0.020 | 511.19 | 65.09 | 277.33 | 0.020 |
| elder_hfgng | 1.0 | 508.40 | 83.49 | 279.35 | 0.016 | 512.79 | 59.89 | 272.67 | 0.005 |
| elder_hfyn | 0.1 | 564.82 | 82.19 | 246.63 | 0.052 | 558.93 | 71.17 | 266.45 | 0.148 |
| elder_hfyn | 0.5 | 565.70 | 83.88 | 242.73 | 0.036 | 559.98 | 68.60 | 261.73 | 0.143 |
| elder_hfyn | 1.0 | 566.73 | 87.05 | 235.38 | 0.006 | 561.88 | 65.77 | 255.95 | 0.094 |
| elder_lfgng | 0.1 | 521.64 | 62.39 | 368.34 | 0.006 | 530.64 | 68.95 | 333.51 | 0.041 |
| elder_lfgng | 0.5 | 523.29 | 67.46 | 359.50 | 0.006 | 530.25 | 60.81 | 329.35 | 0.011 |
| elder_lfgng | 1.0 | 523.37 | 67.70 | 356.20 | 0.002 | 533.09 | 59.45 | 318.33 | 0.008 |
| elder_lfyn | 0.1 | 583.03 | 84.58 | 301.15 | 0.562 | 581.72 | 76.56 | 305.56 | 0.577 |
| elder_lfyn | 0.5 | 584.32 | 86.07 | 296.15 | 0.524 | 584.60 | 78.19 | 296.28 | 0.329 |
| elder_lfyn | 1.0 | 586.72 | 85.93 | 287.48 | 0.470 | 589.73 | 77.85 | 278.47 | 0.027 |
| elder_pseudo | 0.1 | 735.04 | 133.55 | 498.90 | 0.001 | 755.81 | 134.79 | 436.48 | 0.012 |
| elder_pseudo | 0.5 | 733.65 | 135.57 | 499.00 | 0.001 | 754.68 | 132.25 | 438.02 | 0.017 |
| elder_pseudo | 1.0 | 732.54 | 135.87 | 498.14 | 0.000 | 752.31 | 124.65 | 442.19 | 0.014 |
| elder_yn | 0.1 | 572.16 | 81.99 | 275.26 | 0.251 | 567.87 | 73.30 | 288.63 | 0.280 |
| elder_yn | 0.5 | 573.64 | 84.34 | 270.01 | 0.373 | 570.72 | 72.30 | 278.01 | 0.378 |
| elder_yn | 1.0 | 573.82 | 84.87 | 266.60 | 0.246 | 573.48 | 72.59 | 268.80 | 0.159 |
| young_gng | 0.1 | 456.35 | 48.59 | 133.40 | 0.292 | 453.37 | 47.60 | 140.66 | 0.013 |
| young_gng | 0.5 | 456.95 | 47.02 | 132.15 | 0.177 | 456.29 | 43.54 | 134.00 | 0.167 |
| young_gng | 1.0 | 457.70 | 46.28 | 130.55 | 0.096 | 457.63 | 40.37 | 131.00 | 0.013 |
| young_hfgng | 0.1 | 449.79 | 45.31 | 105.15 | 0.707 | 448.42 | 44.89 | 109.02 | 0.565 |
| young_hfgng | 0.5 | 450.77 | 44.72 | 103.91 | 0.500 | 449.62 | 40.74 | 107.45 | 0.704 |
| young_hfgng | 1.0 | 451.94 | 44.75 | 101.09 | 0.208 | 451.50 | 37.51 | 103.23 | 0.226 |
| young_hfyn | 0.1 | 493.66 | 50.92 | 116.16 | 0.032 | 487.17 | 51.93 | 126.49 | 0.009 |
| young_hfyn | 0.5 | 494.62 | 50.74 | 114.27 | 0.054 | 488.97 | 51.00 | 122.73 | 0.025 |
| young_hfyn | 1.0 | 495.77 | 50.10 | 111.55 | 0.083 | 493.08 | 49.40 | 114.69 | 0.170 |
| young_lf | 0.1 | 473.36 | 54.44 | 151.84 | 0.287 | 471.09 | 54.85 | 157.76 | 0.037 |
| young_lf | 0.5 | 474.18 | 55.22 | 148.96 | 0.207 | 474.72 | 51.93 | 148.93 | 0.117 |
| young_lf | 1.0 | 475.03 | 54.10 | 147.35 | 0.067 | 475.22 | 45.69 | 148.46 | 0.019 |
| young_lfgng | 0.1 | 473.36 | 54.44 | 151.84 | 0.290 | 471.09 | 54.85 | 157.76 | 0.054 |
| young_lfgng | 0.5 | 474.18 | 55.22 | 148.96 | 0.201 | 474.72 | 51.93 | 148.93 | 0.119 |
| young_lfgng | 1.0 | 475.03 | 54.10 | 147.35 | 0.068 | 475.22 | 45.69 | 148.46 | 0.021 |
| young_lfyn | 0.1 | 508.16 | 61.53 | 151.83 | 0.228 | 503.17 | 57.27 | 162.27 | 0.776 |
| young_lfyn | 0.5 | 508.79 | 62.11 | 148.82 | 0.306 | 506.82 | 56.33 | 153.58 | 0.713 |
| young_lfyn | 1.0 | 508.92 | 59.52 | 148.67 | 0.278 | 508.72 | 51.89 | 151.43 | 0.545 |
| young_pseudo | 0.1 | 555.42 | 63.03 | 161.81 | 0.951 | 555.36 | 60.57 | 162.27 | 0.858 |
| young_pseudo | 0.5 | 556.11 | 63.54 | 159.16 | 0.364 | 556.92 | 57.17 | 158.77 | 0.194 |
| young_pseudo | 1.0 | 557.18 | 62.50 | 157.25 | 0.096 | 559.57 | 54.06 | 153.59 | 0.021 |
| young_yn | 0.1 | 497.56 | 54.59 | 136.65 | 0.141 | 492.23 | 53.69 | 146.70 | 0.144 |
| young_yn | 0.5 | 498.05 | 54.18 | 135.23 | 0.374 | 495.25 | 52.33 | 139.85 | 0.605 |
| young_yn | 1.0 | 498.17 | 53.86 | 134.10 | 0.556 | 496.97 | 50.70 | 136.71 | 0.494 |
The column % indicates the amount of tail trimmed to the left and right of the data.