{"id":67013,"date":"2026-10-13T11:35:16","date_gmt":"2026-10-13T08:35:16","guid":{"rendered":"https:\/\/wpcalc.com\/en\/?p=67013"},"modified":"2026-10-13T11:35:16","modified_gmt":"2026-10-13T08:35:16","slug":"two-sample-kolmogorov-smirnov-test-calculator","status":"publish","type":"post","link":"https:\/\/wpcalc.com\/en\/statistics\/two-sample-kolmogorov-smirnov-test-calculator\/","title":{"rendered":"Two-Sample Kolmogorov\u2013Smirnov Test Calculator"},"content":{"rendered":"<section class=\"not-prose calculator-box\" aria-labelledby=\"calculator-title\"><div class=\"flex items-baseline sm:items-center justify-between gap-2 sm:gap-3\"><div class=\"flex flex-col sm:flex-row sm:items-center gap-2\"><span class=\"icon icon-calculator text-primary-700! text-base! dark:text-primary-300!\" aria-hidden=\"true\"><\/span><h2 id=\"calculator-title\" class=\"text-lg font-display font-bold\">Compare Two Empirical Distributions<\/h2><\/div><div class=\"calcdash-favorite group\">\n  <button type=\"button\" class=\"favorite\" id=\"favorite\" data-favorite-id=\"67013\" data-favorite-title=\"Two-Sample Kolmogorov\u2013Smirnov Test\" data-favorite-url=\"https:\/\/wpcalc.com\/en\/statistics\/two-sample-kolmogorov-smirnov-test-calculator\/\" data-favorite-excerpt=\"Enter two independent samples and instantly compute the Kolmogorov\u2013Smirnov statistic D and its approximate p-value to test whether both samples come from the same distribution.\" aria-label=\"Add to Favorites\" data-favorite-icon=\"icon icon-wpcalc-bell-curve\">\n    <span class=\"icon icon-shape-star-empty\" aria-hidden=\"true\"><\/span>\n  <\/button>\n  <div class=\"calcdash-favorite__tip\" aria-hidden=\"true\">\n   <span class=\"favorite-tooltip\" id=\"favorite-tooltip\"><\/span>\n  <\/div>\n  <span class=\"sr-only\" role=\"status\" id=\"favorite-status\"><\/span>\n<\/div><\/div><form action=\"https:\/\/wpcalc.com\/en\/statistics\/two-sample-kolmogorov-smirnov-test-calculator\/\" method=\"POST\" class=\"calculator\" id=\"calculator-67013\" data-post=\"67013\"><fieldset class=\"fieldset-input is-1\"><legend class=\"sr-only\">Input Fields<\/legend><div class=\"field\" id=\"input-1\"><label for=\"field-1\">Sample A<\/label><textarea id=\"field-1\" name=\"sample_a\">1; 2; 3; 4; 5; 6; 7; 8; 9; 10<\/textarea><\/div><div class=\"field\" id=\"input-2\"><label for=\"field-2\">Sample B<\/label><textarea id=\"field-2\" name=\"sample_b\">7; 8; 9; 10; 11; 12; 13; 14; 15; 16<\/textarea><\/div><\/fieldset><div class=\"buttons\"><button type=\"submit\" data-text=\"Re-Calculate\" id=\"calculate-button\" data-post=\"67013\">Calculate<\/button><button type=\"reset\">Reset<\/button><\/div><div class=\"field is-checkbox hidden!\" id=\"field-auto-calc\"><input type=\"checkbox\" id=\"auto-calc\"><label for=\"auto-calc\">Calculate automatically<\/label><small>If enabled, the result will update automatically when you change any value.<\/small><\/div><div class=\"fieldset-result is-hidden\" aria-labelledby=\"result-title\" aria-live=\"polite\" role=\"region\"> <h3 class=\"result-title bg-gradient-to-r from-primary-50 to-gray-50 dark:from-primary-900 dark:to-gray-800\" id=\"result-title\"><span class=\"icon icon-s-pulse\" aria-hidden=\"true\"><\/span> Test Results<\/h3><div class=\"result-box\"><div class=\"field-result\" id=\"output-1\"><span class=\"field-title\"><span>Maximum empirical distribution difference<\/span><span class=\"result-term\">D<\/span><\/span><span class=\"field-value\" id=\"result-1\"><\/span><button type=\"button\" class=\"copy-result\" data-tooltip=\"Copy Result\" aria-label=\"Copy Result\"><span class=\"copy-icon icon icon-document-copy\" aria-hidden=\"true\"><\/span><\/button><\/div><div class=\"field-result\" id=\"output-2\"><span class=\"field-title\"><span>Approximate p-value<\/span><span class=\"result-term\">p<\/span><\/span><span class=\"field-value\" id=\"result-2\"><\/span><button type=\"button\" class=\"copy-result\" data-tooltip=\"Copy Result\" aria-label=\"Copy Result\"><span class=\"copy-icon icon icon-document-copy\" aria-hidden=\"true\"><\/span><\/button><\/div><div class=\"field-result\" id=\"output-3\"><span class=\"field-title\"><span>Sample A size<\/span><span class=\"result-term\">n\u2081<\/span><\/span><span class=\"field-value\" id=\"result-3\"><\/span><button type=\"button\" class=\"copy-result\" data-tooltip=\"Copy Result\" aria-label=\"Copy Result\"><span class=\"copy-icon icon icon-document-copy\" aria-hidden=\"true\"><\/span><\/button><\/div><div class=\"field-result\" id=\"output-4\"><span class=\"field-title\"><span>Sample B size<\/span><span class=\"result-term\">n\u2082<\/span><\/span><span class=\"field-value\" id=\"result-4\"><\/span><button type=\"button\" class=\"copy-result\" data-tooltip=\"Copy Result\" aria-label=\"Copy Result\"><span class=\"copy-icon icon icon-document-copy\" aria-hidden=\"true\"><\/span><\/button><\/div><div class=\"field-result is-column\" id=\"output-5\"><span class=\"field-title\"><span>Interpretation<\/span><\/span><span class=\"field-value\" id=\"result-5\"><\/span><button type=\"button\" class=\"copy-result\" data-tooltip=\"Copy Result\" aria-label=\"Copy Result\"><span class=\"copy-icon icon icon-document-copy\" aria-hidden=\"true\"><\/span><\/button><\/div><\/div><div class=\"result-actions\"><button type=\"button\" class=\"copy-link\"><svg viewBox=\"0 0 20 20\" fill=\"currentColor\" aria-hidden=\"true\"><path d=\"M12.232 4.232a2.5 2.5 0 0 1 3.536 3.536l-1.225 1.224a.75.75 0 0 0 1.061 1.06l1.224-1.224a4 4 0 0 0-5.656-5.656l-3 3a4 4 0 0 0 .225 5.865.75.75 0 0 0 .977-1.138 2.5 2.5 0 0 1-.142-3.667l3-3Z\"\/><path d=\"M11.603 7.963a.75.75 0 0 0-.977 1.138 2.5 2.5 0 0 1 .142 3.667l-3 3a2.5 2.5 0 0 1-3.536-3.536l1.225-1.224a.75.75 0 0 0-1.061-1.06l-1.224 1.224a4 4 0 1 0 5.656 5.656l3-3a4 4 0 0 0-.225-5.865Z\"\/><\/svg><span class=\"copy-link__text\">Copy link to this calculation<\/span><\/button><span class=\"sr-only\" role=\"status\" id=\"copy-link-status\"><\/span><\/div><\/div><a href=\"#respond\" class=\"hidden transition-opacity duration-300 opacity-0 w-50 text-sm justify-center items-center gap-2 px-4 py-2 rounded bg-gray-200 text-gray-700 hover:bg-gray-300\" id=\"leave-comment\"><span class=\"icon icon-comments\" aria-hidden=\"true\"><\/span>Leave a Comment<\/a><\/form><\/section><section id=\"calc-reactions\" class=\"not-prose hidden my-12 bg-gradient-to-r from-primary-50 to-gray-50 border border-indigo-100 rounded-xl px-6 py-4 shadow-sm\" data-post=\"67013\" aria-live=\"polite\" aria-labelledby=\"calc-reactions-title\"><p id=\"calc-reactions-title\" class=\"text-sm text-gray-500 text-center mb-2\">How did this result make you feel?<\/p><div role=\"group\" aria-labelledby=\"calc-reactions-title\" class=\"grid grid-cols-3 sm:flex sm:flex-row sm:justify-around gap-4 sm:items-center sm:flex-wrap\"><button type=\"button\" aria-pressed=\"false\" class=\"reaction-btn flex flex-col items-center gap-1 text-sm text-gray-700 hover:text-primary-600 cursor-pointer transition-transform hover:scale-105\" data-reaction=\"like\"><span class=\"reaction-count\" data-reaction-count=\"like\">0<\/span><span class=\"reaction text-3xl\" aria-hidden=\"true\">\ud83d\ude00 <\/span><span class=\"reaction-description font-medium\">Like <\/span><\/button><button type=\"button\" aria-pressed=\"false\" class=\"reaction-btn flex flex-col items-center gap-1 text-sm text-gray-700 hover:text-primary-600 cursor-pointer transition-transform hover:scale-105\" data-reaction=\"helpful\"><span class=\"reaction-count\" data-reaction-count=\"helpful\">0<\/span><span class=\"reaction text-3xl\" aria-hidden=\"true\">\ud83d\udca1 <\/span><span class=\"reaction-description font-medium\">Helpful <\/span><\/button><button type=\"button\" aria-pressed=\"false\" class=\"reaction-btn flex flex-col items-center gap-1 text-sm text-gray-700 hover:text-primary-600 cursor-pointer transition-transform hover:scale-105\" data-reaction=\"confused\"><span class=\"reaction-count\" data-reaction-count=\"confused\">0<\/span><span class=\"reaction text-3xl\" aria-hidden=\"true\">\ud83d\ude15 <\/span><span class=\"reaction-description font-medium\">Confused <\/span><\/button><button type=\"button\" aria-pressed=\"false\" class=\"reaction-btn flex flex-col items-center gap-1 text-sm text-gray-700 hover:text-primary-600 cursor-pointer transition-transform hover:scale-105\" data-reaction=\"disappointed\"><span class=\"reaction-count\" data-reaction-count=\"disappointed\">0<\/span><span class=\"reaction text-3xl\" aria-hidden=\"true\">\ud83d\ude1e <\/span><span class=\"reaction-description font-medium\">Disappointed <\/span><\/button><button type=\"button\" aria-pressed=\"false\" class=\"reaction-btn flex flex-col items-center gap-1 text-sm text-gray-700 hover:text-primary-600 cursor-pointer transition-transform hover:scale-105\" data-reaction=\"inaccurate\"><span class=\"reaction-count\" data-reaction-count=\"inaccurate\">0<\/span><span class=\"reaction text-3xl\" aria-hidden=\"true\">\u274c <\/span><span class=\"reaction-description font-medium\">Inaccurate <\/span><\/button><\/div><div id=\"reaction-message\" class=\"hidden mt-8 rounded-md border border-primary-100 bg-white\/50 backdrop-blur-sm px-4 py-2 text-sm text-center shadow-sm\"><\/div><\/section><div class=\"calcdash-ad not-prose calcdash-ad--calc_result calcdash-ad--in-article\"><ins class=\"adsbygoogle\" style=\"display:block\" data-ad-client=\"ca-pub-1721569815777345\" data-ad-slot=\"6317458308\" data-ad-layout=\"in-article\" data-ad-format=\"fluid\"><\/ins><script>(adsbygoogle = window.adsbygoogle || []).push({});<\/script><\/div>\n<style id=\"wpcoderpro-inline-1\">.formula-box {\r\n\tborder-bottom: none !important;\r\n}<\/style><section class=\"formula-box\" aria-labelledby=\"formula-title\">\r\n\t<div id=\"formula-title\" class=\"not-prose font-display mb-4\"><span class=\"icon icon-formula\" aria-hidden=\"true\"><\/span><h2>Two-Sample Kolmogorov\u2013Smirnov Test Formula<\/h2><\/div>\r\n\t<figure class=\"not-prose formula\">\r\n\t\t<figcaption class=\"formula-title\">Formula<\/figcaption>\r\n\t\t<div class=\"text-base text-gray-800\" id=\"formula\">\n\\[ D = \\max_x \\left| F_1(x) - F_2(x) \\right| \\]\n\\[ n_e = \\frac{n_1 n_2}{n_1 + n_2}, \\qquad \\lambda = \\left( \\sqrt{n_e} + 0.12 + \\frac{0.11}{\\sqrt{n_e}} \\right) D \\]\n<\/div>\r\n\t<\/figure>\r\n\t<\/p>\n<p><strong>Where:<\/strong><\/p>\n<ul>\n<li>\\(F_1(x)\\), \\(F_2(x)\\) \u2014 empirical cumulative distribution functions of the two samples<\/li>\n<li>\\(n_1\\), \\(n_2\\) \u2014 sample sizes<\/li>\n<li>\\(n_e\\) \u2014 effective sample size<\/li>\n<li>\\(D\\) \u2014 maximum vertical distance between the two empirical CDFs<\/li>\n<li>\\(\\lambda\\) \u2014 scaled statistic used in the asymptotic approximation<\/li>\n<\/ul>\n<p>The statistic \\(D\\) measures the largest gap between the two empirical distribution functions. The p-value is obtained from the asymptotic Kolmogorov distribution using Pelz\u2013Good's finite-sample correction: for \\(\\lambda &lt; 1.18\\) a series in odd harmonics is used, otherwise the classical alternating series \\(p = 2\\sum_{k=1}^{\\infty} (-1)^{k+1} e^{-2k^2\\lambda^2}\\).<\/p>\n<p>\r\n<\/section>\n<style id=\"wpcoderpro-inline-459\">.calculation-box {\r\n\tborder-bottom: none !important;\r\n}<\/style><section id=\"calculation\" class=\"calculation-box\" aria-labelledby=\"calculation-title\">\r\n\t<div id=\"calculation-title\" class=\"not-prose font-display\"><span class=\"icon icon-unordered-list\" aria-hidden=\"true\"><\/span><h2>Two-Sample Kolmogorov\u2013Smirnov Test \u2013 Calculation Example<\/h2><\/div>\r\n\r\n<\/p>\n<p><strong>Example:<\/strong> Sample A contains the values 1 to 10 and Sample B the values 7 to 16 (the calculator's default data).<\/p>\n<p>\\[ F_A(x) = \\frac{\\#\\{a_i \\le x\\}}{10}, \\quad F_B(x) = \\frac{\\#\\{b_i \\le x\\}}{10} \\]<\/p>\n<p>Just below 7 we have \\(F_A = 6\/10 = 0.6\\) and \\(F_B = 0\\), a gap of 0.6. Checking every other point shows no larger gap, so:<\/p>\n<p>\\[ D = 0.6, \\qquad n_e = \\frac{10 \\cdot 10}{10 + 10} = 5 \\]<\/p>\n<p>\\[ \\lambda = (\\sqrt{5} + 0.12 + 0.11\/\\sqrt{5}) \\cdot 0.6 \\approx 1.4432 \\quad \\Rightarrow \\quad p \\approx 0.0310 \\]<\/p>\n<p><strong>Result:<\/strong> \\(D = 0.6000\\), p-value \\(\\approx 0.0310\\). Since \\(p &lt; 0.05\\), the samples provide evidence against the hypothesis that they come from the same distribution.<\/p>\n<p>\n\r\n<\/section>\n<h2>How to use the calculator<\/h2>\n<ol>\n<li>Paste or type your first dataset into the <strong>Sample A<\/strong> field. Separate the observations with spaces, semicolons or new lines; decimal commas (e.g. <code>4,2<\/code>) are accepted.<\/li>\n<li>Enter the second, independent dataset into <strong>Sample B<\/strong> using the same format. Each sample must contain between 2 and 5,000 numbers.<\/li>\n<li>Read the <strong>Maximum empirical distribution difference<\/strong> (the D statistic) and the <strong>Approximate p-value<\/strong>, together with the <strong>Sample A size<\/strong> and <strong>Sample B size<\/strong> as a sanity check that all values were parsed.<\/li>\n<li>Check the <strong>Interpretation<\/strong> block for the conclusion at the 5% significance level and any warnings about ties or small samples.<\/li>\n<\/ol>\n<h2>What the two-sample Kolmogorov\u2013Smirnov test does<\/h2>\n<p>The two-sample Kolmogorov\u2013Smirnov (KS) test is a nonparametric test of the null hypothesis that two independent samples were drawn from the same underlying distribution. It works by building the empirical cumulative distribution function (ECDF) of each sample \u2014 the fraction of observations at or below each value \u2014 and finding the largest vertical distance \\(D\\) between the two curves. If the samples really come from the same distribution, this gap should be small; a large gap suggests the distributions differ.<\/p>\n<p>Unlike many classical tests, the KS test is sensitive to <em>any<\/em> kind of difference between distributions: a shift in location (like a change in the mean or median), a difference in spread, skewness, or entirely different distribution shapes. This makes it more general than, say, a <a href=\"https:\/\/wpcalc.com\/en\/statistics\/z-test-for-a-mean-calculator\/\">Z-test for a mean<\/a>, which only compares averages, or rank-based tests such as the <a href=\"https:\/\/wpcalc.com\/en\/statistics\/wilcoxon-signed-rank-test-calculator\/\">Wilcoxon signed-rank test<\/a> and the <a href=\"https:\/\/wpcalc.com\/en\/statistics\/kruskal-wallis-test-calculator\/\">Kruskal\u2013Wallis test<\/a>, which mainly detect location shifts. The price of this generality is somewhat lower power against any one specific alternative.<\/p>\n<p>The test is exact in principle, but this calculator uses an asymptotic approximation with a finite-sample correction, which is accurate to roughly three decimal places when both samples have at least 10 observations and improves as the samples grow. The D statistic itself is always computed exactly from your data.<\/p>\n<h2>Assumptions, limitations and practical tips<\/h2>\n<ul>\n<li><strong>Independence:<\/strong> observations must be independent both within and between samples. For paired or repeated-measures data, use a paired test such as the <a href=\"https:\/\/wpcalc.com\/en\/statistics\/wilcoxon-signed-rank-test-calculator\/\">Wilcoxon signed-rank test<\/a> instead.<\/li>\n<li><strong>Continuous data:<\/strong> the p-value assumes a continuous underlying distribution. With many tied values (e.g. ratings on a 1\u20135 scale or rounded counts), the approximation becomes conservative or unstable; the calculator flags this. For heavily tied ordinal data, consider the Kruskal\u2013Wallis or Friedman test.<\/li>\n<li><strong>Sample size:<\/strong> with fewer than about 10 observations per sample the asymptotic p-value is only a rough guide. The calculator adds a warning when either sample is small; for tiny samples, consult exact KS tables.<\/li>\n<li><strong>Sensitivity:<\/strong> the KS statistic depends on the largest single gap between the ECDFs, which typically occurs near the median. It is comparatively less sensitive to differences in the distribution tails.<\/li>\n<li><strong>Interpreting non-significance:<\/strong> a p-value above 0.05 does not prove the distributions are identical \u2014 it only means the data do not provide enough evidence to distinguish them, especially in small samples. If you are planning a study and want to know whether your sample sizes can realistically detect a given difference, the <a href=\"https:\/\/wpcalc.com\/en\/statistics\/statistical-power-calculator\/\">statistical power calculator<\/a> is a useful companion tool.<\/li>\n<li><strong>Effect size:<\/strong> \\(D\\) itself is a descriptive measure of distributional overlap (0 = identical ECDFs, 1 = fully separated), so report it alongside the p-value rather than relying on significance alone.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Enter two independent samples and instantly compute the Kolmogorov\u2013Smirnov statistic D and its approximate p-value to test whether both samples come from the same distribution.<\/p>\n","protected":false},"author":3168,"featured_media":0,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[74],"tags":[79],"class_list":["post-67013","post","type-post","status-publish","format-standard","hentry","category-statistics","tag-hypothesis-testing"],"acf":[],"_links":{"self":[{"href":"https:\/\/wpcalc.com\/en\/wp-json\/wp\/v2\/posts\/67013","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wpcalc.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wpcalc.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wpcalc.com\/en\/wp-json\/wp\/v2\/users\/3168"}],"replies":[{"embeddable":true,"href":"https:\/\/wpcalc.com\/en\/wp-json\/wp\/v2\/comments?post=67013"}],"version-history":[{"count":1,"href":"https:\/\/wpcalc.com\/en\/wp-json\/wp\/v2\/posts\/67013\/revisions"}],"predecessor-version":[{"id":67014,"href":"https:\/\/wpcalc.com\/en\/wp-json\/wp\/v2\/posts\/67013\/revisions\/67014"}],"wp:attachment":[{"href":"https:\/\/wpcalc.com\/en\/wp-json\/wp\/v2\/media?parent=67013"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wpcalc.com\/en\/wp-json\/wp\/v2\/categories?post=67013"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wpcalc.com\/en\/wp-json\/wp\/v2\/tags?post=67013"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}