[Rcpp-commits] r1966 - pkg/Rcpp/inst/include/Rcpp/stats/random

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Aug 10 09:28:11 CEST 2010


Author: romain
Date: 2010-08-10 09:28:11 +0200 (Tue, 10 Aug 2010)
New Revision: 1966

Modified:
   pkg/Rcpp/inst/include/Rcpp/stats/random/rf.h
Log:
correct rf

Modified: pkg/Rcpp/inst/include/Rcpp/stats/random/rf.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/stats/random/rf.h	2010-08-10 07:23:52 UTC (rev 1965)
+++ pkg/Rcpp/inst/include/Rcpp/stats/random/rf.h	2010-08-10 07:28:11 UTC (rev 1966)
@@ -29,46 +29,49 @@
 class FGenerator_Finite_Finite : public Rcpp::Generator<seed,double> {
 public:
 	
-	FGenerator_Finite_Finite( double n1_, double n2_ ) : n1__2(n1_ / 2.0 ), n2__2(n2_ / 2.0 ) {}
+	FGenerator_Finite_Finite( double n1_, double n2_ ) : 
+		n1(n1_), n2(n2_), n1__2(n1_ / 2.0 ), n2__2(n2_ / 2.0 ) {}
 	
 	inline double operator()() const {
 		// here we know that both n1 and n2 are finite
-		// return ::rchisq( n1 ) / ::rchisq( n2 ) ;
-		return ::rgamma( n1__2, 2.0 ) / ::rgamma( n2__2, 2.0 ) ;
+		// return ( ::rchisq( n1 ) / n1 ) / ( ::rchisq( n2 ) / n2 );
+		return 
+			( ::rgamma( n1__2, 2.0 ) / n1 ) / 
+			( ::rgamma( n2__2, 2.0 ) / n2 ) ;
 	}
 	
 private:
-	double n1__2, n2__2 ;
+	double n1, n2, n1__2, n2__2 ;
 } ;
 
 template <bool seed>
 class FGenerator_NotFinite_Finite : public Rcpp::Generator<seed,double> {
 public:
 	
-	FGenerator_NotFinite_Finite( double n2_ ) : n2__2(n2_ / 2.0 ) {}
+	FGenerator_NotFinite_Finite( double n2_ ) : n2( n2_), n2__2(n2_ / 2.0 ) {}
 	
 	inline double operator()() const {
-		// return 1.0  / ::rchisq( n2 ) ;
-		return 1.0 / ::rgamma( n2__2, 2.0 ) ;
+		// return n2  / ::rchisq( n2 ) ;
+		return n2 / ::rgamma( n2__2, 2.0 ) ;
 	}
 	
 private:
-	double n2__2 ;
+	double n2, n2__2 ;
 } ;
 
 template <bool seed>
 class FGenerator_Finite_NotFinite : public Rcpp::Generator<seed,double> {
 public:
 	
-	FGenerator_Finite_NotFinite( double n1_ ) : n1__2(n1_ / 2.0 ) {}
+	FGenerator_Finite_NotFinite( double n1_ ) : n1(n1_), n1__2(n1_ / 2.0 ) {}
 	
 	inline double operator()() const {
-		// return ::rchisq( n1 ) ;
-		return ::rgamma( n1__2, 2.0 ) ;
+		// return ::rchisq( n1 ) / n1 ;
+		return ::rgamma( n1__2, 2.0 ) / n1 ;
 	}
 	
 private:
-	double n1__2 ;
+	double n1, n1__2 ;
 } ;
 
 template <bool seed>



More information about the Rcpp-commits mailing list