NCBI C++ ToolKit
sls_alp_regression.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: sls_alp_regression.hpp 44808 2010-02-18 16:10:58Z boratyng $
2 * ===========================================================================
3 *
4 * PUBLIC DOMAIN NOTICE
5 * National Center for Biotechnology Information
6 *
7 * This software/database is a "United States Government Work" under the
8 * terms of the United States Copyright Act. It was written as part of
9 * the author's offical duties as a United States Government employee and
10 * thus cannot be copyrighted. This software/database is freely available
11 * to the public for use. The National Library of Medicine and the U.S.
12 * Government have not placed any restriction on its use or reproduction.
13 *
14 * Although all reasonable efforts have been taken to ensure the accuracy
15 * and reliability of the software and data, the NLM and the U.S.
16 * Government do not and cannot warrant the performance or results that
17 * may be obtained by using this software or data. The NLM and the U.S.
18 * Government disclaim all warranties, express or implied, including
19 * warranties of performance, merchantability or fitness for any particular
20 * purpose.
21 *
22 * Please cite the author in any work or product based on this material.
23 *
24 * ===========================================================================*/
25 
26 /*****************************************************************************
27 
28 File name: sls_alp_regression.hpp
29 
30 Author: Sergey Sheetlin
31 
32 Contents: Regression methods
33 
34 ******************************************************************************/
35 
36 #ifndef ALGO_BLAST_GUMBEL_PARAMS__INCLUDED_SLS_ALP_REGRESSION
37 #define ALGO_BLAST_GUMBEL_PARAMS__INCLUDED_SLS_ALP_REGRESSION
38 
39 #include <complex>
40 #include <iostream>
41 #include <map>
42 #include <vector>
43 #include <fstream>
44 #include <float.h>
45 #include <algorithm>
46 
47 #include <corelib/ncbistl.hpp>
48 #include <corelib/ncbitype.h>
49 #include <corelib/ncbi_limits.h>
50 
51 #include "sls_alp_data.hpp"
52 
53 
55 BEGIN_SCOPE(blast)
56 
57 
58 BEGIN_SCOPE(Sls)
59 
60  typedef double function_type(double x_,void* func_number_);
61 
62 
63  class alp_reg{
64 
65 
66 
67  public:
68 
69 
70  alp_reg(//constructor
71  );
72 
73 
74  ~alp_reg();//destructor
75 
76  static void find_tetta_general(
77  function_type *func_,
78  void* func_pointer_,
79  double a_,//[a,b] is the interval for search of equation solution
80  double b_,
81  Int4 n_partition_,
82  double eps_,
83  std::vector<double> &res_);
84 
85  static double find_single_tetta_general(
86  function_type *func_,
87  void* func_pointer_,
88  double a_,//[a,b] is the interval for search of equation solution
89  double b_,
90  double eps_);
91 
92  static void correction_of_errors(
93  double *errors_,
94  Int4 number_of_elements_);
95 
96 
97  static void robust_regression_sum_with_cut_LSM(
98  Int4 min_length_,
99  Int4 number_of_elements_,
100  double *values_,
101  double *errors_,
102  bool cut_left_tail_,
103  bool cut_right_tail_,
104  double y_,
105  double &beta0_,
106  double &beta1_,
107  double &beta0_error_,
108  double &beta1_error_,
109  Int4 &k1_opt_,
110  Int4 &k2_opt_,
111  bool &res_was_calculated_);
112 
113  static double function_for_robust_regression_sum_with_cut_LSM(
114  double *values_,
115  double *errors_,
116  Int4 number_of_elements_,
117  Int4 k_start_,
118  double c_,
119  double &beta0_,
120  double &beta1_,
121  double &beta0_error_,
122  double &beta1_error_,
123  bool &res_was_calculated_);
124 
125  static void robust_regression_sum_with_cut_LSM_beta1_is_defined(
126  Int4 min_length_,
127  Int4 number_of_elements_,
128  double *values_,
129  double *errors_,
130  bool cut_left_tail_,
131  bool cut_right_tail_,
132  double y_,
133  double &beta0_,
134  double beta1_,
135  double &beta0_error_,
136  double beta1_error_,
137  Int4 &k1_opt_,
138  Int4 &k2_opt_,
139  bool &res_was_calculated_);
140 
141  static double function_for_robust_regression_sum_with_cut_LSM_beta1_is_defined(
142  double *values_,
143  double *errors_,
144  Int4 number_of_elements_,
145  Int4 k_start_,
146  double c_,
147  double &beta0_,
148  double beta1_,
149  double &beta0_error_,
150  double beta1_error_,
151  bool &res_was_calculated_);
152 
153  static double error_of_the_lg(//lg(v1_)
154  double v1_,
155  double v1_error_);
156 
157  static double error_of_the_sqrt(//sqrt(v1_)
158  double v1_,
159  double v1_error_);
160 
161  static double error_of_the_ratio(//v1_/v2_
162  double v1_,
163  double v1_error_,
164  double v2_,
165  double v2_error_);
166 
167  static double error_of_the_product(//v1_*v2_
168  double v1_,
169  double v1_error_,
170  double v2_,
171  double v2_error_);
172 
173  static double error_of_the_sum(//v1_+v2_
174  double v1_,
175  double v1_error_,
176  double v2_,
177  double v2_error_);
178 
179 
180  inline static double sqrt_for_errors(
181  double x_)
182  {
183  if(x_<=0)
184  {
185  return 0.0;
186  }
187  else
188  {
189  return sqrt(x_);
190  };
191  };
192 
193 
194  static double median(
195  Int4 dim_,
196  double *array_);
197 
198  static double robust_sum(
199  double *values,
200  Int4 dim,
201  Int4 N_points,
202  bool *&remove_flag);
203 
204 
205  };
206 
207 END_SCOPE(Sls)
208 
209 END_SCOPE(blast)
211 
212 #endif //! ALGO_BLAST_GUMBEL_PARAMS__INCLUDED_SLS_ALP_REGRESSION
static double sqrt_for_errors(double x_)
int32_t Int4
4-byte (32-bit) signed integer
Definition: ncbitype.h:102
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
The NCBI C++/STL use hints.
Defines Limits for the types used in NCBI C/C++ toolkit.
double function_type(double x_, void *func_number_)
Modified on Fri Sep 20 14:57:10 2024 by modify_doxy.py rev. 669887