- Timestamp:
- 08/20/09 00:54:47 (15 years ago)
- Location:
- library/bdm/stat
- Files:
-
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
library/bdm/stat/discrete.h
r565 r569 23 23 24 24 //! Rectangular support 25 //! Support po nits are located inbetween ranges! For example:25 //! Support points are located inbetween ranges! For example: 26 26 //! For ranges=[0,1] and gridsizes=[1] the support point is 0.5 27 27 class rectangular_support: public root { … … 89 89 return ind; 90 90 } 91 //! set the first corner toactvec91 //! set the first vector to corner and store result in actvec 92 92 const vec& first_vec(){ 93 93 for ( int j = 0; j < dim; j++ ) { … … 146 146 UIREGISTER(rectangular_support); 147 147 148 //! Discrete support with stored support points 149 class discrete_support: public root{ 150 protected: 151 //! storage of support points 152 Array<vec> Spoints; 153 //! index in iterators 154 int idx; 155 public: 156 //! Default constructor 157 discrete_support() : Spoints(0), idx(0){} 158 //! Access function 159 int points() const {return Spoints.length();} 160 //! set the first vector to corner and store result in actvec 161 const vec& first_vec(){bdm_assert_debug(Spoints.length()>0,"Empty support");idx=0; return Spoints(idx);} 162 //! set next vector after calling first_vec() 163 const vec& next_vec(){bdm_assert_debug(Spoints.length()>idx-1,"Out of support points"); return Spoints(++idx);} 164 165 /*! 166 \code 167 class = "discrete_support"; 168 points = ( [1,2..], [2,2..], ...); // list of points 169 === OR === 170 epdf = {class="epdf_offspring",...}; // epdf rfom which to sample 171 npoints = 100; // number of samples 172 \endcode 173 */ 174 void from_setting (const Setting &set) { 175 UI::get (Spoints, set, "points", UI::compulsory); 176 if (points()<1){ 177 int npoints; 178 shared_ptr<epdf> ep= UI::build<epdf>(set, "epdf", UI::compulsory); 179 if (!UI::get(npoints,set,"npoints",UI::optional)){npoints=100;} 180 181 //sample 182 Spoints.set_size(npoints); 183 for(int i=0; i<points(); i++){Spoints(i)=ep->sample();} 184 } 185 } 186 //! access function 187 Array<vec> & _Spoints() {return Spoints;} 188 }; 189 UIREGISTER(discrete_support); 190 148 191 class grid_fnc: public fnc{ 149 192 protected: -
library/bdm/stat/exp_family.h
r565 r569 1145 1145 //! Set sample 1146 1146 void set_parameters (int n0, bool copy = true) {n = n0; w.set_size (n0, copy);samples.set_size (n0, copy);}; 1147 //! Set samples 1148 void set_parameters (const Array<vec> &Av) { 1149 bdm_assert_debug(Av.size()>0,"Empty samples"); 1150 n = Av.size(); 1151 epdf::set_parameters(Av(0).length()); 1152 w=1/n*ones(n); 1153 samples=Av; 1154 }; 1147 1155 //! Potentially dangerous, use with care. 1148 1156 vec& _w() {return w;}; -
library/bdm/stat/merger.h
r565 r569 143 143 samples ( j ) = Sup.next_vec(); 144 144 } 145 } 146 //! Set support points from dicrete grid 147 void set_support ( discrete_support &Sup) { 148 Npoints = Sup.points(); 149 eSmp.set_parameters(Sup._Spoints()); 145 150 } 146 151 //! set debug file