STK++ 0.9.13
STK_Law_FisherSnedecor.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------*/
2/* Copyright (C) 2004-2016 Serge Iovleff, Université Lille 1, Inria
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with this program; if not, write to the
16 Free Software Foundation, Inc.,
17 59 Temple Place,
18 Suite 330,
19 Boston, MA 02111-1307
20 USA
21
22 Contact : S..._Dot_I..._At_stkpp_Dot_org (see copyright for ...)
23*/
24
25/*
26 * Project: stkpp::STatistiK::Law
27 * Purpose: FisherSnedecor probability distribution.
28 * Author: Serge Iovleff, S..._Dot_I..._At_stkpp_Dot_org (see copyright for ...)
29 **/
30
35#ifndef STK_LAW_FISHERSNEDECOR
36#define STK_LAW_FISHERSNEDECOR
37
38#include "STK_Law_IUnivLaw.h"
39
40namespace STK
41{
42
43namespace Law
44{
62class FisherSnedecor: public IUnivLaw<Real>
63{
64 public:
69 inline FisherSnedecor( int df1 = 1., int df2 = 1)
70 : Base(_T("Fisher-Snedecor")), df1_(df1), df2_(df2)
71 {};
73 inline virtual ~FisherSnedecor() {}
75 inline int df1() const { return df1_;}
77 inline int df2() const { return df2_;}
79 inline void setDf1( int df1)
80 {
82 df1_ = df1;
83 }
85 inline void setDf2( int df2)
86 {
88 df2_ = df2;
89 }
91 virtual Real rand() const;
95 virtual Real pdf(Real const& x) const;
99 virtual Real lpdf(Real const& x) const;
103 virtual Real cdf(Real const& t) const;
107 virtual Real icdf(Real const& p) const;
108
112 static Real rand( int df1, int df2);
117 static Real pdf(Real const& x, int df1, int df2);
122 static Real lpdf(Real const& x, int df1, int df2);
127 static Real cdf(Real const& t, int df1, int df2);
132 static Real icdf(Real const& p, int df1, int df2);
133
134#ifdef IS_RTKPP_LIB
136 virtual Real lcdf( Real const& t) const;
138 virtual Real cdfc( Real const& t) const;
140 virtual Real lcdfc( Real const& t) const;
141#endif
142
143 protected:
145 int df1_;
147 int df2_;
148};
149
150#ifdef IS_RTKPP_LIB
151
152inline Real FisherSnedecor::rand() const
153{
154#ifdef _OPENMP
155//#pragma omp critical
156#endif
157GetRNGstate(); Real s = Rf_rf(df1_, df2_); PutRNGstate(); return s;
158}
159
160inline Real FisherSnedecor::pdf(Real const& x) const { return Rf_df(x, df1_, df2_, false);}
161inline Real FisherSnedecor::lpdf(Real const& x) const { return Rf_df(x, df1_, df2_, true);}
162inline Real FisherSnedecor::cdf(Real const& t) const { return Rf_pf(t, df1_, df2_, true, false);}
163inline Real FisherSnedecor::lcdf(Real const& t) const { return Rf_pf(t, df1_, df2_, true, true);}
164inline Real FisherSnedecor::cdfc(Real const& t) const { return Rf_pf(t, df1_, df2_, false, false);}
165inline Real FisherSnedecor::lcdfc(Real const& t) const { return Rf_pf(t, df1_, df2_, false, true);}
166inline Real FisherSnedecor::icdf(Real const& p) const { return Rf_qf(p, df1_, df2_, true, false);}
167
168inline Real FisherSnedecor::rand( int df1, int df2)
169{
170#ifdef _OPENMP
171//#pragma omp critical
172#endif
173GetRNGstate(); Real s = Rf_rf(df1, df2); PutRNGstate(); return s;
174}
175
176inline Real FisherSnedecor::pdf(Real const& x, int df1, int df2)
177{ return Rf_df(x, df1, df2, false);}
178inline Real FisherSnedecor::lpdf(Real const& x, int df1, int df2)
179{ return Rf_df(x, df1, df2, true);}
180inline Real FisherSnedecor::cdf(Real const& t, int df1, int df2)
181{ return Rf_pf(t, df1, df2, true, false);}
182inline Real FisherSnedecor::icdf(Real const& p, int df1, int df2)
183{ return Rf_qf(p, df1, df2, true, false);}
184
185#endif
186
187} // namespace Law
188
189} // namespace STK
190
191#endif /*STK_LAW_FISHERSNEDECOR*/
In this file we define the interface base class IUnivLaw for all probabilities laws.
#define STKDOMAIN_ERROR_1ARG(Where, Arg, Error)
Definition STK_Macros.h:165
#define _T(x)
Let x unmodified.
FisherSnedecor distribution law.
virtual Real cdf(Real const &t) const
virtual ~FisherSnedecor()
destructor
virtual Real pdf(Real const &x) const
int df2_
Second degree of freedom.
int df1_
First degree of freedom.
virtual Real icdf(Real const &p) const
virtual Real lpdf(Real const &x) const
FisherSnedecor(int df1=1., int df2=1)
Default constructor.
Interface base class for all the univariate distributions.
virtual Real cdfc(Real const &t) const
calculate the complement of cumulative distribution function, called in statistics the survival funct...
virtual Real lcdfc(Real const &t) const
calculate the log-complement of cumulative distribution function Give the log-probability that a rand...
virtual Real lcdf(Real const &t) const
compute the lower tail log-cumulative distribution function Give the log-probability that a random va...
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
double Real
STK fundamental type of Real values.
The namespace STK is the main domain space of the Statistical ToolKit project.