contrib/mul/pdf1d/pdf1d_weighted_epanech_kernel_pdf.h
Go to the documentation of this file.
00001 // This is mul/pdf1d/pdf1d_weighted_epanech_kernel_pdf.h
00002 #ifndef pdf1d_weighted_epanech_kernel_pdf_h
00003 #define pdf1d_weighted_epanech_kernel_pdf_h
00004 
00005 //:
00006 // \file
00007 // \brief Univariate Weighted Epanechnikov kernel PDF
00008 // \author Ian Scott
00009 
00010 #include <pdf1d/pdf1d_pdf.h>
00011 #include <pdf1d/pdf1d_weighted_kernel_pdf.h>
00012 
00013 //: Univariate Epanechnikov kernel PDF $k(x)=0.75(1-0.2x^2)/\sqrt{2}$
00014 class pdf1d_weighted_epanech_kernel_pdf : public pdf1d_weighted_kernel_pdf
00015 {
00016  public:
00017   //: Dflt ctor
00018   pdf1d_weighted_epanech_kernel_pdf();
00019 
00020   //: Define n kernels centred at i*sep (i=0..n-1)
00021   pdf1d_weighted_epanech_kernel_pdf(int n, double sep, double width);
00022 
00023   //: Destructor
00024   virtual ~pdf1d_weighted_epanech_kernel_pdf();
00025 
00026   //: Create a sampler object on the heap
00027   // Caller is responsible for deletion.
00028   virtual pdf1d_sampler* new_sampler() const;
00029 
00030   //: Probability density at x
00031   virtual double operator()(double x) const;
00032 
00033   //: Log of probability density at x
00034   virtual double log_p(double x) const;
00035 
00036   //: Cumulative Probability (P(x'<x) for x' drawn from the distribution)
00037   virtual double cdf(double x) const;
00038 
00039   //: Return true if cdf() uses an analytic implementation
00040   virtual bool cdf_is_analytic() const;
00041 
00042   //: Gradient of PDF at x
00043   virtual double gradient(double x, double& p) const;
00044 
00045   //: Compute nearest point to x which has a density above a threshold
00046   //  If log_p(x)>log_p_min then x returned unchanged.  Otherwise x is moved
00047   //  (typically up the gradient) until log_p(x)>=log_p_min.
00048   // \param x This may be modified to the nearest plausible position.
00049   // \param log_p_min lower threshold for log_p(x)
00050   virtual double nearest_plausible(double x, double log_p_min) const;
00051 
00052   //: Version number for I/O
00053   short version_no() const;
00054 
00055   //: Name of the class
00056   virtual vcl_string is_a() const;
00057 
00058   //: Does the name of the class match the argument?
00059   virtual bool is_class(vcl_string const& s) const;
00060 
00061   //: Create a copy on the heap and return base class pointer
00062   virtual pdf1d_pdf* clone() const;
00063 
00064   friend class pdf1d_weighted_epanech_kernel_sampler;
00065 };
00066 
00067 #endif // pdf1d_weighted_epanech_kernel_pdf_h