/* $Id: $ * =========================================================================== * * PUBLIC DOMAIN NOTICE * National Center for Biotechnology Information * * This software/database is a "United States Government Work" under the * terms of the United States Copyright Act. It was written as part of * the author's offical duties as a United States Government employee and * thus cannot be copyrighted. This software/database is freely available * to the public for use. The National Library of Medicine and the U.S. * Government have not placed any restriction on its use or reproduction. * * Although all reasonable efforts have been taken to ensure the accuracy * and reliability of the software and data, the NLM and the U.S. * Government do not and cannot warrant the performance or results that * may be obtained by using this software or data. The NLM and the U.S. * Government disclaim all warranties, express or implied, including * warranties of performance, merchantability or fitness for any particular * purpose. * * Please cite the author in any work or product based on this material. * * ===========================================================================*/ /***************************************************************************** File name: sls_alp_regression.cpp Author: Sergey Sheetlin Contents: Regression methods ******************************************************************************/ #include "sls_alp_regression.hpp" using namespace Sls; using namespace std; //-------------------------Solution of arbitrary equations---------------------------- void alp_reg::find_tetta_general( function_type *func_, void* func_pointer_, double a_,//[a,b] is the interval for search of equation solution double b_, long int n_partition_, double eps_, std::vector &res_ ) { res_.resize(0); vector intervals(0); if(n_partition_<=0) { throw error("Error in alp_reg::find_tetta_general\n",4); }; long int i; double h=(b_-a_)/n_partition_; double x1,x2 = 0.0; for(i=0;i=eps_&&fabs(x2)>=eps_)) { intervals.push_back(i); }; }; for(i=0;i<(long int)intervals.size();i++) { double sol=find_single_tetta_general( func_, func_pointer_, a_+intervals[i]*h,//[a,b] is the interval for search of equation solution a_+(1+intervals[i])*h, eps_); res_.push_back(sol); }; sort(res_.begin(),res_.end()); return; } double alp_reg::find_single_tetta_general( function_type *func_, void* func_pointer_, double a_,//[a,b] is the interval for search of equation solution double b_, double eps_ ) { if(b_eps_) { double x12=(x1+x2)/2; double y12=(*func_)(//calculation of E(exp(tetta*X)) x12, func_pointer_); if(fabs(y12) array_vect(dim_); long int i; for(i=0;i > array_vect(dim); for(i=0;i P; P.first=-fabs(values[i]-med_val); P.second=i; array_vect[i]=P; }; sort(array_vect.begin(),array_vect.end()); for(i=0;i