CMS 3D CMS Logo

Public Member Functions | Private Attributes

BinomialNoncentralInterval< Sorter > Class Template Reference

#include <BinomialNoncentralInterval.h>

Inheritance diagram for BinomialNoncentralInterval< Sorter >:
BinomialInterval TNamed

List of all members.

Public Member Functions

void calculate (const double X, const double n)
bool find_rho_set (const double rho, const int ntot, int &x_l, int &x_r) const
bool neyman (const int ntot, const int nrho, double *rho, double *x_l, double *x_r)

Private Attributes

Sorter sorter_

Detailed Description

template<typename Sorter>
class BinomialNoncentralInterval< Sorter >

Definition at line 31 of file BinomialNoncentralInterval.h.


Member Function Documentation

template<typename Sorter>
void BinomialNoncentralInterval< Sorter >::calculate ( const double  X,
const double  n 
) [inline, virtual]

Implements BinomialInterval.

Definition at line 80 of file BinomialNoncentralInterval.h.

                                             {
      rho = (rho_min + rho_max)/2;
      find_rho_set(rho, int(n), x_l, x_r);
      if (x_r < X)
        rho_min = rho;
      else
        rho_max = rho;
    }
    lower_ = rho;
  
    // Binary search for the largest rho whose acceptance set has left
    // endpoint X; this is the upper endpoint of the rho interval.
    rho_min = 0; rho_max = 1;
    while (std::fabs(rho_max - rho_min) > tol) {
      rho = (rho_min + rho_max)/2;
      find_rho_set(rho, int(n), x_l, x_r);
      if (x_l > X)
        rho_max = rho;
      else
        rho_min = rho;
    }
    upper_ = rho;
  }

 private:
template<typename Sorter>
bool BinomialNoncentralInterval< Sorter >::find_rho_set ( const double  rho,
const int  ntot,
int &  x_l,
int &  x_r 
) const [inline]

Definition at line 37 of file BinomialNoncentralInterval.h.

Referenced by BinomialNoncentralInterval< FeldmanCousinsSorter >::calculate(), and BinomialNoncentralInterval< FeldmanCousinsSorter >::neyman().

                                                    {
      sum += probs[i].prob();
      const int& x = probs[i].x();
      if (x < x_l) x_l = x;
      if (x > x_r) x_r = x;
    }
  
    return x_l <= x_r;
  }

  // Construct nrho acceptance sets in rho = [0,1] given ntot trials
template<typename Sorter>
bool BinomialNoncentralInterval< Sorter >::neyman ( const int  ntot,
const int  nrho,
double *  rho,
double *  x_l,
double *  x_r 
) [inline, virtual]

Reimplemented from BinomialInterval.

Definition at line 67 of file BinomialNoncentralInterval.h.

                                   {
      rho[i] = double(i)/nrho;
      find_rho_set(rho[i], ntot, xL, xR);
      x_l[i] = xL;
      x_r[i] = xR;
    }
    return true;
  }

  // Given X successes and n trials, calculate the interval using the

Member Data Documentation

template<typename Sorter>
Sorter BinomialNoncentralInterval< Sorter >::sorter_ [private]

Definition at line 115 of file BinomialNoncentralInterval.h.