[Distr-commits] r376 - branches/distr-2.1/pkg/distr/R branches/distr-2.1/pkg/distr/chm branches/distr-2.1/pkg/distr/man pkg/distr/R pkg/distr/man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Jan 16 15:43:05 CET 2009
Author: ruckdeschel
Date: 2009-01-16 15:43:05 +0100 (Fri, 16 Jan 2009)
New Revision: 376
Modified:
branches/distr-2.1/pkg/distr/R/Convpow.r
branches/distr-2.1/pkg/distr/chm/ConvPow.html
branches/distr-2.1/pkg/distr/chm/Distr.chm
branches/distr-2.1/pkg/distr/man/ConvPow.Rd
pkg/distr/R/Convpow.r
pkg/distr/man/ConvPow.Rd
Log:
fixed a small buglet in convpow().
Modified: branches/distr-2.1/pkg/distr/R/Convpow.r
===================================================================
--- branches/distr-2.1/pkg/distr/R/Convpow.r 2009-01-12 15:31:57 UTC (rev 375)
+++ branches/distr-2.1/pkg/distr/R/Convpow.r 2009-01-16 14:43:05 UTC (rev 376)
@@ -126,6 +126,8 @@
if (N==0) return(Dirac(0))
if (N==1) return(D1)
e1 <- as(D1, "UnivarLebDecDistribution")
+ if(is(e1,"DiscreteDistribution")) return(convpow(e1,N))
+ if(is(e1,"AbscontDistribution")) return(convpow(e1,N))
aw1 <- acWeight(e1)
dw1 <- 1-aw1
@@ -166,8 +168,21 @@
})
#
###############################################################################
-
setMethod("convpow",
+ signature(D1 = "DiscreteDistribution"),
+ function(D1, N){
+ if( !.isNatural0(N))
+ stop("N has to be a natural (or 0)")
+ if (N==0) return(Dirac(0))
+ if (N==1) return(D1)
+ if (N==2) return(D1+D1)
+ D11 <- if (N%%2==1) D1 else Dirac(0)
+ DN1 <- convpow(D1,N%/%2)
+ return((DN1+DN1)+D11)
+ })
+###############################################################################
+
+setMethod("convpow",
signature(D1 = "Norm"),
function(D1, N)
{if( !.isNatural0(N))
Modified: branches/distr-2.1/pkg/distr/chm/ConvPow.html
===================================================================
--- branches/distr-2.1/pkg/distr/chm/ConvPow.html 2009-01-12 15:31:57 UTC (rev 375)
+++ branches/distr-2.1/pkg/distr/chm/ConvPow.html 2009-01-16 14:43:05 UTC (rev 376)
@@ -11,6 +11,7 @@
<param name="keyword" value="R: convpow,AbscontDistribution-method">
<param name="keyword" value="R: convpow,LatticeDistribution-method">
<param name="keyword" value="R: convpow,DiscreteDistribution-method">
+<param name="keyword" value="R: convpow,AcDcLcDistribution-method">
<param name="keyword" value="R: convpow,Norm-method">
<param name="keyword" value="R: convpow,Binom-method">
<param name="keyword" value="R: convpow,Nbinom-method">
@@ -45,6 +46,8 @@
convpow(D1,N)
## S4 method for signature 'DiscreteDistribution':
convpow(D1,N)
+ ## S4 method for signature 'AcDcLcDistribution':
+ convpow(D1,N)
</pre>
@@ -140,6 +143,6 @@
-<hr><div align="center">[Package <em>distr</em> version 2.1 <a href="00Index.html">Index]</a></div>
+<hr><div align="center">[Package <em>distr</em> version 2.1 <a href="00Index.html">Index</a>]</div>
</body></html>
Modified: branches/distr-2.1/pkg/distr/chm/Distr.chm
===================================================================
(Binary files differ)
Modified: branches/distr-2.1/pkg/distr/man/ConvPow.Rd
===================================================================
--- branches/distr-2.1/pkg/distr/man/ConvPow.Rd 2009-01-12 15:31:57 UTC (rev 375)
+++ branches/distr-2.1/pkg/distr/man/ConvPow.Rd 2009-01-16 14:43:05 UTC (rev 376)
@@ -6,6 +6,7 @@
\alias{convpow,AbscontDistribution-method}
\alias{convpow,LatticeDistribution-method}
\alias{convpow,DiscreteDistribution-method}
+\alias{convpow,AcDcLcDistribution-method}
\alias{convpow,Norm-method}
\alias{convpow,Binom-method}
\alias{convpow,Nbinom-method}
@@ -26,6 +27,7 @@
\S4method{convpow}{AbscontDistribution}(D1,N)
\S4method{convpow}{LatticeDistribution}(D1,N)
\S4method{convpow}{DiscreteDistribution}(D1,N)
+ \S4method{convpow}{AcDcLcDistribution}(D1,N)
}
\arguments{
Modified: pkg/distr/R/Convpow.r
===================================================================
--- pkg/distr/R/Convpow.r 2009-01-12 15:31:57 UTC (rev 375)
+++ pkg/distr/R/Convpow.r 2009-01-16 14:43:05 UTC (rev 376)
@@ -126,6 +126,8 @@
if (N==0) return(Dirac(0))
if (N==1) return(D1)
e1 <- as(D1, "UnivarLebDecDistribution")
+ if(is(e1,"DiscreteDistribution")) return(convpow(e1,N))
+ if(is(e1,"AbscontDistribution")) return(convpow(e1,N))
aw1 <- acWeight(e1)
dw1 <- 1-aw1
@@ -166,8 +168,21 @@
})
#
###############################################################################
-
setMethod("convpow",
+ signature(D1 = "DiscreteDistribution"),
+ function(D1, N){
+ if( !.isNatural0(N))
+ stop("N has to be a natural (or 0)")
+ if (N==0) return(Dirac(0))
+ if (N==1) return(D1)
+ if (N==2) return(D1+D1)
+ D11 <- if (N%%2==1) D1 else Dirac(0)
+ DN1 <- convpow(D1,N%/%2)
+ return((DN1+DN1)+D11)
+ })
+###############################################################################
+
+setMethod("convpow",
signature(D1 = "Norm"),
function(D1, N)
{if( !.isNatural0(N))
Modified: pkg/distr/man/ConvPow.Rd
===================================================================
--- pkg/distr/man/ConvPow.Rd 2009-01-12 15:31:57 UTC (rev 375)
+++ pkg/distr/man/ConvPow.Rd 2009-01-16 14:43:05 UTC (rev 376)
@@ -6,6 +6,7 @@
\alias{convpow,AbscontDistribution-method}
\alias{convpow,LatticeDistribution-method}
\alias{convpow,DiscreteDistribution-method}
+\alias{convpow,AcDcLcDistribution-method}
\alias{convpow,Norm-method}
\alias{convpow,Binom-method}
\alias{convpow,Nbinom-method}
@@ -26,6 +27,7 @@
\S4method{convpow}{AbscontDistribution}(D1,N)
\S4method{convpow}{LatticeDistribution}(D1,N)
\S4method{convpow}{DiscreteDistribution}(D1,N)
+ \S4method{convpow}{AcDcLcDistribution}(D1,N)
}
\arguments{
More information about the Distr-commits
mailing list