The `ump`

package for R
(see package info on the
main page for this site for how to get it)
has a function `umpu.binom`

that calculates the critical
function φ(`x`, α, θ) for the UMPU randomized
(two-tailed) test, where `x` is the data,
α is the significance level,
and θ is the parameter value assumed by the null hypothesis.

In particular, the data `x` is assumed to
be Binomial(`n`, θ) distributed, where θ is the
success probability.

For example, suppose the data is 17 successes out of 25 trials and
the null hypothesis is θ = 0.5. The randomized test for
α = 0.05 rejects the null hypothesis with probability
(click the Submit

button to see the result).

You can edit this box to change the numbers and re-submit to do a different analysis.

Any one of the numbers, except the sample size 25, can be made a vector,
for example, the following code gives the values of the critical function
for all possible `x` values and checks that
the `umpu.binom`

actually calculates what it claims to
(the last two lines of output should each repeat the same number).

If we make θ a vector in the preceding example we have a so-called
*fuzzy confidence interval*.

Suppose, as in the first example, the data is 17 successes out of 25 trials and we want a 95% confidence interval (so α = 0.05). The fuzzy confidence interval corresponding to the UMPU test has a membership function calculated and plotted by

A somewhat clearer visualization of the edges of the fuzzy interval is given by the following code.

This code also prints the so-called *support* and *core*
of the interval (four significant figure approximations thereto).

If we make α a vector we get the so-called
*fuzzy P-value*.

Suppose, as in the first example,
the data is 17 successes out of 25 trials and
we want an α = 0.05 level UMPU two-tailed test of the null hypothesis
θ = 0.5. The following code calculates and plots the (membership
function of) the fuzzy `P`-value.

The function plotted here has another interpretation.
It can also be considered to be the distribution function
of an abstract random variable,
the so-called *randomized P-value*.

In either case the function is continuous and nondecreasing and its domain is the whole parameter space, the interval [0, 1]. The plot only shows the interesting part. The function is zero to the left of the plot region and one to the right.

The derivative of the distribution function is the density function. We happen to know the distribution function is piecewise linear. Hence the density is piecewise constant (a step function).