Changeset 253


Ignore:
Timestamp:
Mar 3, 2005, 12:08:37 PM (17 years ago)
Author:
Peter
Message:

modified prediction function in RegressionLocal? to take a ostream

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/RegressionLinear.h

    r235 r253  
    8989      y = alpha_ + beta_ * (x-m_x_);
    9090      y_err = sqrt( alpha_var_+beta_var_*(x-m_x_)*(x-m_x_)+s2_/w );
     91      x_=x;
     92      y_=y;
     93      y_err_=y_err;
    9194    }
    9295
  • trunk/src/RegressionLocal.cc

    r245 r253  
    1919  }
    2020
    21   void RegressionLocal::fit(const double f, const u_int step_size)
     21  void RegressionLocal::fit(std::ostream& s, const double f,
     22                            const u_int step_size)
    2223  {
    2324    sort(data_.begin(), data_.end());
     25    regressor_->print_header(s);
     26    s << std::endl;
    2427
    2528    // number of points on each side
     
    5255      }
    5356
    54 
    5557      // copying data
    5658      // Peter, too much copying. Move the copying outside loop and
     
    7779      regressor_->predict(x_[x_.size()-1], y_[y_.size()-1],
    7880                          y_err_[y_err_.size()-1]);
     81      regressor_->print(s);
     82      s << std::endl;
    7983    }
    8084  }
    8185
    82   std::ostream& RegressionLocal::print(std::ostream& s) const
    83   {
    84     for (size_t i=0; i<x_.size(); i++) {
    85       regressor_->print(s);
    86       s << std::endl;
    87     }
    88     return s;
    89   }
    9086
    9187
  • trunk/src/RegressionLocal.h

    r235 r253  
    7575    /// data points are used and the point where the fit is done is in
    7676    /// the middle. Starting with the smallest x, the function jumps
    77     /// \a step_size point in each iteration to do the next fit
     77    /// \a step_size point in each iteration to do the next
     78    /// fit. Result is sent to ostream \a s.
    7879    ///
    79     void fit(const double fraction, const u_int step_size=1);
     80    void fit(std::ostream& s, const double fraction, const u_int step_size=1);
    8081
    81     ///
    82     /// @return prediction values and parameters
    83     ///
    84     std::ostream& print(std::ostream&) const;
    85              
    86     ///
    87     /// @return header for print()
    88     ///
    89     inline std::ostream& print_header(std::ostream& s) const
    90     { return regressor_->print_header(s); }
     82 
    9183
    9284         
Note: See TracChangeset for help on using the changeset viewer.