00001 #ifndef GETSTART_H
00002 #define GETSTART_H
00003
00004 #include "psychometric.h"
00005 #include "data.h"
00006
00007 #include <list>
00008 #include <vector>
00009
00011 class PsiGrid {
00012 private:
00013 unsigned int ndim;
00014 unsigned int ngrid;
00015 std::vector< std::vector<double> > grid1d;
00016 std::vector<double> lower_bounds;
00017 std::vector<double> upper_bounds;
00018 public:
00019 PsiGrid ( void ) {}
00020 PsiGrid (
00021 const std::vector<double>& xmin,
00022 const std::vector<double>& xmax,
00023 unsigned int gridsize
00024 );
00025 PsiGrid shift ( const std::vector<double>& newposition ) const;
00026 PsiGrid shrink ( const std::vector<double>& newposition ) const;
00027 PsiGrid subgrid ( void ) const;
00028 unsigned int get_gridsize ( void ) const { return grid1d.front().size(); }
00029 bool empty ( void ) const { return grid1d.empty(); }
00030 const std::vector<double>& front ( void ) const { return grid1d.front(); }
00031 unsigned int dimension ( void ) const { return grid1d.size(); }
00032 double get_lower ( unsigned int i ) const { return lower_bounds[i]; }
00033 double get_upper ( unsigned int i ) const { return upper_bounds[i]; }
00034 double get_incr ( unsigned int i ) const { return (get_upper(i)-get_lower(i))/(get_gridsize()-1); }
00035 double operator() ( unsigned int i, unsigned int j ) const { return grid1d[i][j]; }
00036 };
00037
00038 std::vector<double> linspace (
00039 double xmin,
00040 double xmax,
00041 unsigned int n
00042 );
00043
00044 void makegridpoints (
00045 const PsiGrid& grid,
00046 std::vector<double> prm,
00047 unsigned int pos,
00048 std::list< std::vector<double> > *gridpoints
00049 );
00050
00051 void evalgridpoints (
00052 const std::list< std::vector<double> >& grid,
00053 std::list< std::vector<double> > *bestprm,
00054 std::list< double > *L,
00055 const PsiData* data,
00056 const PsiPsychometric* pmf,
00057 unsigned int nbest
00058 );
00059
00060 void updategridpoints (
00061 const PsiGrid& grid,
00062 const std::list< std::vector<double> >& bestprm,
00063 std::list< std::vector<double> > *newgridpoints,
00064 std::list< PsiGrid > *newgrids
00065 );
00066
00067 void a_range ( const PsiData* data, double *xmin, double *xmax );
00068 void b_range ( const PsiData* data, double *xmin, double *xmax );
00069 void lm_range ( const PsiData* data, double *xmin, double *xmax );
00070 void gm_range ( const PsiData* data, double *xmin, double *xmax );
00071
00072 void parameter_range ( const PsiData* data, const PsiPsychometric* pmf, unsigned int prmindex, double *xmin, double *xmax );
00073
00074 std::vector<double> getstart (
00075 const PsiPsychometric* pmf,
00076 const PsiData* data,
00077 unsigned int gridsize,
00078 unsigned int nneighborhoods,
00079 unsigned int niterations,
00080 std::vector<double> *incr=NULL
00081 );
00082
00083 std::vector<double> pymakegridpoints (
00084 const PsiGrid& grid,
00085 std::vector<double> prm,
00086 unsigned int pos
00087 );
00088
00089 #endif