• Main Page
  • Classes
  • Files
  • File List

src/integrate.h

00001 #ifndef INTEGRATE_H
00002 #define INTEGRATE_H
00003 
00004 #include "psychometric.h"
00005 #include "data.h"
00006 #include "getstart.h"
00007 #include "bootstrap.h"
00008 #include <vector>
00009 #include <algorithm>
00010 
00012 std::vector<double> lingrid ( double xmin, double xmax, unsigned int gridsize );
00013 
00014 // Numerical integration
00015 void normalize_probability (
00016                 const std::vector<double>& x, 
00017                 std::vector<double>& fx       
00018                 );  
00019 
00020 double numerical_mean (
00021                 const std::vector<double>& x,  
00022                 const std::vector<double>& fx  
00023                 );  
00024 
00025 double numerical_variance (
00026                 const std::vector<double>& x,  
00027                 const std::vector<double>& fx, 
00028                 double m                       
00029                 );  
00030 
00031 // Moment matching
00032 std::vector<double> match_gauss (
00033                 const std::vector<double>& x,  
00034                 const std::vector<double>& fx  
00035                 );  
00036 std::vector<double> match_gamma (
00037                 const std::vector<double>& x,  
00038                 const std::vector<double>& fx  
00039                 );  
00040 std::vector<double> match_beta (
00041                 const std::vector<double>& x,  
00042                 const std::vector<double>& fx  
00043                 );  
00044 
00045 
00047 class PsiIndependentPosterior {
00048         private:
00049                 unsigned int nparams;
00050                 std::vector<PsiPrior*> fitted_posteriors;
00051                 std::vector< std::vector<double> > grids;
00052                 std::vector< std::vector<double> > margins;
00053         public:
00054                 PsiIndependentPosterior (
00055                                 unsigned int nprm,                    
00056                                 std::vector<PsiPrior*> posteriors,    
00057                                 std::vector< std::vector<double> > x, 
00058                                 std::vector< std::vector<double> > fx 
00059                                 );
00060                 PsiIndependentPosterior ( const PsiIndependentPosterior& post ) :
00061                         nparams ( post.nparams ), fitted_posteriors ( post.nparams ), grids ( post.grids ), margins ( post.margins )
00062                         { unsigned int i; for ( i=0; i<nparams; i++ ) fitted_posteriors[i] = post.fitted_posteriors[i]->clone(); }
00063                 ~PsiIndependentPosterior ( void ) { unsigned int i; for ( i=0; i<nparams; i++ ) delete fitted_posteriors[i]; }
00064                 PsiPrior *get_posterior ( unsigned int parameter ) { return fitted_posteriors[parameter]->clone(); } 
00065                 std::vector<double> get_grid ( unsigned int parameter ) { return grids[parameter]; } 
00066                 std::vector<double> get_margin ( unsigned int parameter ) { return margins[parameter]; } 
00067 };
00068 
00069 PsiIndependentPosterior independent_marginals (
00070                 const PsiPsychometric *pmf,    
00071                 const PsiData *data            
00072                 );  
00073 
00074 MCMCList sample_posterior (
00075                 const PsiPsychometric *pmf,    
00076                 const PsiData *data,           
00077                 PsiIndependentPosterior& post, 
00078                 unsigned int nsamples=600,     
00079                 unsigned int propose=25        
00080                 );   
00081 
00082 void sample_diagnostics (
00083                 const PsiPsychometric *pmf,   
00084                 const PsiData *data,          
00085                 MCMCList *samples             
00086                 );  
00087 
00088 #endif

Generated on Mon Jul 4 2011 14:52:04 for Psi++ by  doxygen 1.7.1