Table of contents

Introduction
Which browsers?
Examples
Run a JavaScript program
License, revision date, and e-mail address

Introduction

confidence interval of the population median

This file contains a program to get a confidence interval of the population median. It is nonparametric and conservative and small-sample and nonrandomized, and it handles ties correctly. It uses the binomial distribution. That is, it is nearly all one could wish for in confidence of the median.

k-sample test

However, that is not why I wrote it. I use it to work a k-sample test. The resulting test is wretched, in that it has low power. However, I respectfully suggest that all the competing tests are more wretched. That is, the new test is nonparametric and conservative and small-sample and nonrandomized, and it handles ties and heteroskedasticity correctly: but each of the older tests fails to be or do one or more of these. The supposed power of the older tests is an illusion. Testing with one of those older tests is like walking in a swamp, or so I think.

confidence interval of the difference of two population medians

Also I use confidence intervals of two population medians to build a confidence interval of the difference of two population medians. This too is wretched. I respectfully suggest that the competing intervals are more wretched.

warnings about grammar

In the following paragraphs are some examples showing use of the program. The user is respectfully invited to try out these examples or to use any others. The only thing to remember is: follow the grammatical rules of JavaScript. (This is because the “eval” method of JavaScript is used in picking up the data from the upper text area.) In particular, the user is respectfully reminded that integers beginning with a zero digit may be understood to be in base eight. To top.

Which browsers?

Any modern Web browser can do this page, just so its JavaScript is turned on. If yours seems to be turned off, please ask for help from your classmates, children, spouse, or teacher. To top.

Examples

confidence interval of the population median

Perhaps a statistician wishes to find a 95% confidence interval for the population median of the population from which the numbers “6, 5, 7, 89, 88, 5, 4, 3, 4, 66, 2, 12, 34, 75, 89, 4” have been chosen at random with replacement. An easy way is to select and copy
[
.05,
[ 6,5,7,89,88,5,4,3,4,66,2,12,34,75,89,4 ]
]
and then move to the upper text area, and then paste into that uppertext area, and them click with the mouse on the “Median Confidence” button. Then the lower text area will contain
     4 <= population median <= 75
This means that all the numbers from 4 to 75 inclusive are in the interval. The confidence may be more than 95%, because the binomial distribution has a discrete domain. The confidence cannot be less than 95%. The numbers in the sample need not be nonnegative integers; any numbers legal in JavaScript will do. Ties are permitted. Actually, this 95% two-sided confidence interval is two simultaneous 97.5% one-sided confidence intervals, one for the left side and one for the right side.

simultaneous confidence intervals

Of course, a statistician usually works more than one inference at a time. Here is an example where three independent samples, each from a possibly different population, are inferred together, using Bonferroni’s correction for multiple inference:
[
.05,
[ 6,5,7,89,88,5,-4,3,0.676,66,2,12,34,75,89,4 ],
[ 132,432,564,6667,76.341,1234,556,700,9876 ],
[ -12,-13,-5,4,77,876,56,47,1243,34,67,98 ]
]
This time there are three answers, one for each sample:
     2 <= population median <= 88
     76.341 <= population median <= 9876
     -12 <= population median <= 876
The reader will notice that the first sample is the same as before, but its confidence interval is a little wider, because of the Bonferroni correction.

k-sample test

Perhaps a statistician would like to know if all the three populations could have the same population median. It seems that they could. For instance, 80 could be that median, because it lies in all three confidence intervals. If the intersection of the three confidence intervals were empty, then one would infer that the three populations could not all have the same population median. This test is wretched and has low power, because it combines three other tests. However, I have failed to find a competing test that is less wretched.

confidence interval of the difference of two population medians

Sometimes a researcher wishes to infer a confidence interval for the difference between the population medians of two populations. Let us consider the first and second populations above. The most positive number in the first confidence interval is 88, and the most negative number in the second confidence interval is 76.341, so the right boundary we seek is 88-76.341 . The most negative number in the first confidence interval is 2, and the most positive number in the second confidence interval is 9876, so the left boundary we seek is 2-9876 . Therefore the confidence interval that we are looking for is the closed interval [ 2-9876, 88-76.341 ]. By arithmetic this interval is [ -9874, 11.659 ]. This is for first median minus second median. Reversing order and sign we find the answer for second median minus first median is [ -11.659, +9874 ]. These answers are wretched.

infinity

So far all the alpha values have been 5%. Perhaps a statistician would rather use 1%. Then the array might look like
[
.01,
[ 6,5,7,89,88,5,-4,3,0.676,66,2,12,34,75,89,4 ],
[ 132,432,564,6667,76.341,1234,556,700,9876 ],
[ -12,-13,-5,4,77,876,56,47,1243,34,67,98 ]
]
where only the .05 has been changed, to .01, but everything else is unchanged. Then we get for our answers
     0.676 <= population median <= 89
     -Infinity <= population median <= Infinity
     -13 <= population median <= 1243
The reader sees that all three of the confidence intervals are wider than before. The interval in the middle is very much wider, all the way from minus infinity to plus infinity. To top.

Run a JavaScript program

While building this page I needed a way to run little JavaScript programs, so I constructed the “Run a JavaScript program” button. When I was done I left the button so users could practice JavaScript programming with it. If a grammatically correct JavaScript program is in the upper text area, the button will run it. Here is a trivial example:
var x=[];
for(var j=0;j<10;j++)x[j]=j;
x;
The user is respectfully invited to use the “Run a JavaScript program” button on this. The answer will be
0,1,2,3,4,5,6,7,8,9
To top.

License, revision date, and e-mail address

This file, including the program, is in the public domain. The date of this revision is 6 March 2012. Criticism both constructive and destructive comes to me, Harold Kaplan,
       at     dot        
smtw2gh  gmail   com
Harold Kaplan’s statistics.htm
John C. Pezzullo’s page
To top.