rStats.js v1.3.0
    Preparing search index...

    Function ksTest

    • Kolmogorov-Smirnov test. Equivalent to R's ks.test(). Takes a distribution function given as a function (for example (q) => pnorm(q)) or a second sample. NaN values are dropped.

      As R, warnings has "ties should not be present for the one-sample Kolmogorov-Smirnov test" for one sample with ties, and "p-value will be approximate in the presence of ties" for two samples with ties and exact: false (or m n >= 10000).

      Parameters

      • x: Sample

        Sample.

      • y: Sample | ((q: number) => number)

        A continuous distribution function, or a second sample.

      • Optionaloptions: KsTestOptions

        See KsTestOptions.

        There is also a formula form for two samples, ksTest("y ~ g", data, options) (next overload).

      Returns KsTestResult

      const x = [0.61, -1.2, 0.33, 1.57, -0.42, 0.08, -0.85, 1.1];
      ksTest(x, (q) => pnorm(q)).pValue; // 0.9716870044206776
      ksTest(x, [0.9, 2.1, 1.4, 2.8, 1.7, 0.4]).statistic; // 0.625
    • Two-sample Kolmogorov-Smirnov test from a formula and a data frame. As R's ks.test(formula, data): "y ~ g" compares the two levels of g (the first level is x). Only the variables of the formula count: the rows where one of them is missing are dropped.

      Parameters

      Returns KsTestResult