[Distr-commits] r406 - in branches/distr-2.1/pkg/distr: R chm inst/doc man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Feb 27 19:49:27 CET 2009
Author: ruckdeschel
Date: 2009-02-27 19:49:27 +0100 (Fri, 27 Feb 2009)
New Revision: 406
Modified:
branches/distr-2.1/pkg/distr/R/0distrOptions.R
branches/distr-2.1/pkg/distr/R/AllInitialize.R
branches/distr-2.1/pkg/distr/R/DiscreteDistribution.R
branches/distr-2.1/pkg/distr/R/internalUtils.R
branches/distr-2.1/pkg/distr/chm/00Index.html
branches/distr-2.1/pkg/distr/chm/DiscreteDistribution-class.html
branches/distr-2.1/pkg/distr/chm/DiscreteDistribution.html
branches/distr-2.1/pkg/distr/chm/Distr.chm
branches/distr-2.1/pkg/distr/chm/Distr.toc
branches/distr-2.1/pkg/distr/chm/distroptions.html
branches/distr-2.1/pkg/distr/chm/internals.html
branches/distr-2.1/pkg/distr/inst/doc/Rplots.pdf
branches/distr-2.1/pkg/distr/inst/doc/newDistributions.pdf
branches/distr-2.1/pkg/distr/man/DiscreteDistribution-class.Rd
branches/distr-2.1/pkg/distr/man/DiscreteDistribution.Rd
branches/distr-2.1/pkg/distr/man/distroptions.Rd
branches/distr-2.1/pkg/distr/man/internals.Rd
Log:
implemented proposal by jacob van etten
Modified: branches/distr-2.1/pkg/distr/R/0distrOptions.R
===================================================================
--- branches/distr-2.1/pkg/distr/R/0distrOptions.R 2009-02-26 19:57:26 UTC (rev 405)
+++ branches/distr-2.1/pkg/distr/R/0distrOptions.R 2009-02-27 18:49:27 UTC (rev 406)
@@ -11,7 +11,9 @@
withgaps = TRUE,
simplifyD = TRUE,
DistrCollapse = TRUE,
- withSweave = FALSE
+ withSweave = FALSE,
+ ## new Items after mail by Jacob van Etter, 27-02-09
+ DistrCollapse.Unique.Warn = FALSE
)
distroptions <- function(...) {
if (nargs() == 0) return(.distroptions)
Modified: branches/distr-2.1/pkg/distr/R/AllInitialize.R
===================================================================
--- branches/distr-2.1/pkg/distr/R/AllInitialize.R 2009-02-26 19:57:26 UTC (rev 405)
+++ branches/distr-2.1/pkg/distr/R/AllInitialize.R 2009-02-27 18:49:27 UTC (rev 406)
@@ -174,8 +174,7 @@
len = length(support)
if(len > 1){
- if(min(support[2:len] - support[1:(len - 1)]) <
- getdistrOption("DistrResolution"))
+ if(diff(support) < getdistrOption("DistrResolution"))
stop("grid too narrow --> change DistrResolution")
}
Modified: branches/distr-2.1/pkg/distr/R/DiscreteDistribution.R
===================================================================
--- branches/distr-2.1/pkg/distr/R/DiscreteDistribution.R 2009-02-26 19:57:26 UTC (rev 405)
+++ branches/distr-2.1/pkg/distr/R/DiscreteDistribution.R 2009-02-27 18:49:27 UTC (rev 406)
@@ -5,7 +5,12 @@
## (c) Matthias Kohl: revised P.R. 030707
DiscreteDistribution <- function(supp, prob, .withArith = FALSE,
- .withSim = FALSE, .lowerExact = TRUE, .logExact = FALSE){
+ .withSim = FALSE, .lowerExact = TRUE, .logExact = FALSE,
+ .DistrCollapse =
+ getdistrOption("DistrCollapse"),
+ .DistrCollapse.Unique.Warn =
+ getdistrOption(".DistrCollapse.Unique.Warn"),
+ .DistrResolution = getdistrOption("DistrResolution")){
if(!is.numeric(supp))
stop("'supp' is no numeric vector")
if(any(!is.finite(supp))) # admit +/- Inf?
@@ -24,23 +29,34 @@
if(!all(prob >= 0))
stop("'prob' contains values < 0")
}
- if(length(usupp <- unique(supp)) < len){
- warning("collapsing to unique support values")
- prob <- as.vector(tapply(prob, supp, sum))
- supp <- sort(usupp)
- len <- length(supp)
- rm(usupp)
- }else{
- o <- order(supp)
- supp <- supp[o]
- prob <- prob[o]
- rm(o)
- }
+
+ o <- order(supp)
+ supp <- supp[o]
+ prob <- prob[o]
+ rm(o)
- if(len > 1){
- if(min(diff(supp)) <
- getdistrOption("DistrResolution") )
- stop("grid too narrow --> change DistrResolution")
+ if(.DistrCollapse){
+ if (len>1 && min(diff(supp))< .DistrResolution){
+ erg <- .DistrCollapse(supp, prob, .DistrResolution)
+ if (len>length(erg$prob) && .DistrCollapse.Unique.Warn)
+ warning("collapsing to unique support values")
+ prob <- erg$prob
+ supp <- erg$supp
+ }
+ }else{
+ usupp <- unique(supp)
+ if(length(usupp) < len){
+ if(.DistrCollapse.Unique.Warn)
+ warning("collapsing to unique support values")
+ prob <- as.vector(tapply(prob, supp, sum))
+ supp <- sort(usupp)
+ len <- length(supp)
+ rm(usupp)
+ }
+ if(len > 1){
+ if(min(diff(supp))< .DistrResolution)
+ stop("grid too narrow --> change DistrResolution")
+ }
}
rm(len)
@@ -238,30 +254,20 @@
#supp.u <- unique(supp)
- len = length(supp)
+ len <- length(supp)
if(len > 1){
- if(min(abs(diff(supp))) < getdistrOption("DistrResolution"))
- {if(!getdistrOption("DistrCollapse"))
+ if (min(diff(supp))< getdistrOption("DistrResolution")){
+ if (getdistrOption("DistrCollapse")){
+ erg <- .DistrCollapse(supp, prob,
+ getdistrOption("DistrResolution"))
+ if ( len > length(erg$prob) &&
+ getdistrOption("DistrCollapse.Unique.Warn") )
+ warning("collapsing to unique support values")
+ prob <- erg$prob
+ supp <- erg$supp
+ }else
stop("grid too narrow --> change DistrResolution")
- else
- {supp1 <- 0*supp
- prob1 <- 0*prob
- xo <- supp[1]-1
- j <- 0
- for(i in seq(along=supp))
- {if (abs(supp[i]-xo) > getdistrOption("DistrResolution"))
- { j <- j+1
- supp1[j] <- supp[i]
- prob1[j] <- prob[i]
- xo <- supp1[j]
- }
- else { prob1[j] <- prob1[j]+prob[i] }
- }
- prob <- prob1[1:j]
- supp <- supp1[1:j]
- rm(prob1,supp1,i,j,xo)
- }
}
}
Modified: branches/distr-2.1/pkg/distr/R/internalUtils.R
===================================================================
--- branches/distr-2.1/pkg/distr/R/internalUtils.R 2009-02-26 19:57:26 UTC (rev 405)
+++ branches/distr-2.1/pkg/distr/R/internalUtils.R 2009-02-27 18:49:27 UTC (rev 406)
@@ -1092,3 +1092,21 @@
}
return(li0)
}
+
+#------------------------------------------------------------------------------
+# .DistributionAggregate by Jacob van Etten, jacobvanetten at yahoo.com
+# on a mail on Feb 27th 2009
+#------------------------------------------------------------------------------
+.DistrCollapse <- function(support, prob,
+ eps = getdistrOption("DistrResolution")){
+ supp <- support
+ prob <- as.vector(prob)
+ suppIncr <- diff(c(supp[1]-2*eps,supp)) < eps
+ groups <- cumsum(!suppIncr)
+ prob <- as.vector(tapply(prob, groups, sum))
+ supp <- as.vector(tapply(supp, groups, quantile, probs = 0.5, type = 1))
+ ### in order to get a "support member" take the leftmost median
+ return(list(supp = supp, prob = prob))
+# newDistribution <- DiscreteDistribution(supp=supp,prob=prob)
+# return(newDistribution)
+}
Modified: branches/distr-2.1/pkg/distr/chm/00Index.html
===================================================================
--- branches/distr-2.1/pkg/distr/chm/00Index.html 2009-02-26 19:57:26 UTC (rev 405)
+++ branches/distr-2.1/pkg/distr/chm/00Index.html 2009-02-27 18:49:27 UTC (rev 406)
@@ -534,6 +534,10 @@
<td>functions to change the global variables of the package 'distr'</td></tr>
<tr><td width="25%"><a href="Distribution-class.html">Distribution-class</a></td>
<td>Class "Distribution"</td></tr>
+<tr><td width="25%"><a href="distroptions.html">DistributionAggregate</a></td>
+<td>functions to change the global variables of the package 'distr'</td></tr>
+<tr><td width="25%"><a href="distroptions.html">DistributionAggregate.Unique.Warn</a></td>
+<td>functions to change the global variables of the package 'distr'</td></tr>
<tr><td width="25%"><a href="DistrList.html">DistrList</a></td>
<td>Generating function for DistrList-class</td></tr>
<tr><td width="25%"><a href="DistrList-class.html">DistrList-class</a></td>
Modified: branches/distr-2.1/pkg/distr/chm/DiscreteDistribution-class.html
===================================================================
--- branches/distr-2.1/pkg/distr/chm/DiscreteDistribution-class.html 2009-02-26 19:57:26 UTC (rev 405)
+++ branches/distr-2.1/pkg/distr/chm/DiscreteDistribution-class.html 2009-02-27 18:49:27 UTC (rev 406)
@@ -166,8 +166,24 @@
<h3>Note</h3>
<p>
-Working with a computer, we use a finite interval as support which carries at least mass <code>1-getdistrOption("TruncQuantile")</code>.
+Working with a computer, we use a finite interval as support which
+carries at least mass <code>1-getdistrOption("TruncQuantile")</code>. <br>
</p>
+<p>
+Also, we require that support points have distance at least
+<code>getdistrOption("DistrResoltion")</code>, if this condition fails,
+upon a suggestion by Jacob van Etten, <a href="mailto:jacobvanetten at yahoo.com">jacobvanetten at yahoo.com</a>,
+we use the global option <code>getdistrOption("DistrCollapse")</code> to
+decide whether we use collapsing or not. If we do so, we collapse support
+points if they are too close to each other, taking
+the (left most) median among them as new support point which accumulates
+all the mass of the collapsed points.
+With <code>getdistrOption("DistrCollapse")==FALSE</code>, we at least collapse
+points according to the result of <code>unique()</code>, and if after this
+collapsing, the minimal distance is less than <code>getdistrOption("DistrResoltion")</code>,
+we throw an error. By <code>getdistrOption("DistrCollapse.Unique.Warn")</code>,
+we control, whether we throw a warning upon collapsing or not.
+</p>
<h3>Author(s)</h3>
@@ -218,6 +234,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/DiscreteDistribution.html
===================================================================
--- branches/distr-2.1/pkg/distr/chm/DiscreteDistribution.html 2009-02-26 19:57:26 UTC (rev 405)
+++ branches/distr-2.1/pkg/distr/chm/DiscreteDistribution.html 2009-02-27 18:49:27 UTC (rev 406)
@@ -24,7 +24,11 @@
<pre>
DiscreteDistribution(supp, prob, .withArith=FALSE, .withSim=FALSE,
- .lowerExact = TRUE, .logExact = FALSE)
+ .lowerExact = TRUE, .logExact = FALSE,
+ .DistrCollapse = getdistrOption("DistrCollapse"),
+ .DistrCollapse.Unique.Warn =
+ getdistrOption(".DistrCollapse.Unique.Warn"),
+ .DistrResolution = getdistrOption("DistrResolution"))
DiscreteDistribution(supp)
</pre>
@@ -56,6 +60,20 @@
<td>
normally not set by the user: whether in determining slots <code>d,p,q</code>,
we make particular use of a logarithmic representation to enhance accuracy.</td></tr>
+<tr valign="top"><td><code>.DistrCollapse</code></td>
+<td>
+controls whether in generating a new discrete
+distribution, support points closer together than <code>.DistrResolution</code> are
+collapsed.</td></tr>
+<tr valign="top"><td><code>.DistrCollapse.Unique.Warn</code></td>
+<td>
+controls whether there is a warning
+whenever collapsing occurs or when two points are collapsed by a call to
+<code>unique()</code> (default behaviour if <code>.DistrCollapse</code> is <code>FALSE</code>)</td></tr>
+<tr valign="top"><td><code>.DistrResolution</code></td>
+<td>
+minimal spacing between two mass points in a discrete
+distribution</td></tr>
</table>
<h3>Details</h3>
@@ -74,8 +92,24 @@
<h3>Note</h3>
<p>
-Working with a computer, we use a finite interval as support which carries at least mass <code>1-getdistrOption("TruncQuantile")</code>.
+Working with a computer, we use a finite interval as support which
+carries at least mass <code>1-getdistrOption("TruncQuantile")</code>. <br>
</p>
+<p>
+Also, we require that support points have distance at least
+<code>.DistrResoltion</code>, if this condition fails,
+upon a suggestion by Jacob van Etten, <a href="mailto:jacobvanetten at yahoo.com">jacobvanetten at yahoo.com</a>,
+we use the global option <code>.DistrCollapse</code> to
+decide whether we use collapsing or not. If we do so, we collapse support
+points if they are too close to each other, taking
+the (left most) median among them as new support point which accumulates
+all the mass of the collapsed points.
+With <code>.DistrCollapse==FALSE</code>, we at least collapse
+points according to the result of <code>unique()</code>, and if after this
+collapsing, the minimal distance is less than <code>.DistrResoltion</code>,
+we throw an error. By <code>.DistrCollapse.Unique.Warn</code>,
+we control, whether we throw a warning upon collapsing or not.
+</p>
<h3>Author(s)</h3>
@@ -110,6 +144,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/chm/Distr.toc
===================================================================
--- branches/distr-2.1/pkg/distr/chm/Distr.toc 2009-02-26 19:57:26 UTC (rev 405)
+++ branches/distr-2.1/pkg/distr/chm/Distr.toc 2009-02-27 18:49:27 UTC (rev 406)
@@ -942,6 +942,14 @@
<param name="Local" value="Distribution-class.html">
</OBJECT>
<LI> <OBJECT type="text/sitemap">
+<param name="Name" value="DistributionAggregate">
+<param name="Local" value="distroptions.html">
+</OBJECT>
+<LI> <OBJECT type="text/sitemap">
+<param name="Name" value="DistributionAggregate.Unique.Warn">
+<param name="Local" value="distroptions.html">
+</OBJECT>
+<LI> <OBJECT type="text/sitemap">
<param name="Name" value="DistrList">
<param name="Local" value="DistrList.html">
</OBJECT>
Modified: branches/distr-2.1/pkg/distr/chm/distroptions.html
===================================================================
--- branches/distr-2.1/pkg/distr/chm/distroptions.html 2009-02-26 19:57:26 UTC (rev 405)
+++ branches/distr-2.1/pkg/distr/chm/distroptions.html 2009-02-27 18:49:27 UTC (rev 406)
@@ -19,6 +19,8 @@
<param name="keyword" value="R: WarningSim">
<param name="keyword" value="R: withSweave">
<param name="keyword" value="R: withgaps">
+<param name="keyword" value="R: DistributionAggregate">
+<param name="keyword" value="R: DistributionAggregate.Unique.Warn">
<param name="keyword" value=" functions to change the global variables of the package ‘distr’">
</object>
@@ -75,7 +77,7 @@
<dl>
<dt><code>DefaultNrGridPoints</code></dt><dd>default number of grid points in integration, default value: <code>2^12</code></dd>
<dt><code>DistrResolution</code></dt><dd>minimal spacing between two mass points in a discrete distribution, default value: <code>1e-6</code></dd>
-<dt><code>DistrCollapse</code></dt><dd>logical; in convolving discrete distributions, shall support points
+<dt><code>DistrCollapse</code></dt><dd>logical; in discrete distributions, shall support points
with distance smaller than <code>DistrResolution</code> be collapsed; default value: <code>TRUE</code></dd>
<dt><code>TruncQuantile</code></dt><dd>argument for <code>q</code>-slot at which to truncate; also, for discrete distributions,
support is restricted to [<code>q(TruncQuantile)</code>,<code>q(1-TruncQuantile)</code>], default value: <code>1e-5</code></dd>
@@ -97,6 +99,10 @@
—default <code>TRUE</code></dd>
<dt><code>simplifyD</code></dt><dd>controls whether in the return value of arithmetic
operations there is a call to <code>simplifyD</code> or not —default <code>TRUE</code></dd>
+<dt><code>DistrCollapse.Unique.Warn</code></dt><dd>controls whether there is a warning
+whenever collapsing occurs or when two points are collapsed by a call to
+<code>unique()</code> (default behaviour if <code>DistrCollapse</code> is <code>FALSE</code>);
+—default <code>FALSE</code></dd>
</dl>
<h3>Author(s)</h3>
@@ -144,6 +150,6 @@
</script>
-<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/internals.html
===================================================================
--- branches/distr-2.1/pkg/distr/chm/internals.html 2009-02-26 19:57:26 UTC (rev 405)
+++ branches/distr-2.1/pkg/distr/chm/internals.html 2009-02-27 18:49:27 UTC (rev 406)
@@ -60,6 +60,7 @@
<param name="keyword" value="R: .trunc.up">
<param name="keyword" value="R: .trunc.low">
<param name="keyword" value="R: .modifyqgaps">
+<param name="keyword" value="R: .DistrCollapse">
<param name="keyword" value="R: devNew">
<param name="keyword" value=" Internal functions of package distr">
</object>
@@ -139,6 +140,7 @@
.trunc.up(object, upper)
.trunc.low(object, lower)
.modifyqgaps(pfun, qfun, gaps, leftright = "left")
+.DistrCollapse(support, prob, eps = getdistrOption("DistrResolution"))
devNew(...)
</pre>
@@ -284,6 +286,9 @@
<tr valign="top"><td><code>support</code></td>
<td>
support vector of a univariate discrete distribution</td></tr>
+<tr valign="top"><td><code>prob</code></td>
+<td>
+probability vector for a univariate discrete distribution</td></tr>
<tr valign="top"><td><code>mixDistr</code></td>
<td>
an object of class <code>UnivarDistrList</code></td></tr>
@@ -655,6 +660,16 @@
<tr valign="top"><td><code>.trunc.up,.trunc.low</code></td>
<td>
a list with elements <code>r,p,d,q</code> (in this order).</td></tr>
+<tr valign="top"><td><code>.DistrCollapse</code></td>
+<td>
+upon a suggestion by Jacob van Etten,
+<a href="mailto:jacobvanetten at yahoo.com">jacobvanetten at yahoo.com</a>: help function to collapse the support
+points of a discrete distributions if they are too close to each other;
+here argument <code>support</code> is the (original; already sorted) support
+and <code>prob</code> a corresponding probability vector of same length.
+Criterium for collapsing: a distance smaller than argument
+<code>eps</code>.
+</td></tr>
<tr valign="top"><td><code>devNew</code></td>
<td>
returns the return value of the device opened,
Modified: branches/distr-2.1/pkg/distr/inst/doc/Rplots.pdf
===================================================================
--- branches/distr-2.1/pkg/distr/inst/doc/Rplots.pdf 2009-02-26 19:57:26 UTC (rev 405)
+++ branches/distr-2.1/pkg/distr/inst/doc/Rplots.pdf 2009-02-27 18:49:27 UTC (rev 406)
@@ -2,8 +2,8 @@
%âãÏÓ\r
1 0 obj
<<
-/CreationDate (D:20090220154756)
-/ModDate (D:20090220154756)
+/CreationDate (D:20090227184829)
+/ModDate (D:20090227184829)
/Title (R Graphics Output)
/Producer (R 2.9.0)
/Creator (R)
@@ -47,7 +47,7 @@
38.97 172.78 m 148.04 172.78 l S
38.97 227.22 m 148.04 227.22 l S
38.97 281.66 m 148.04 281.66 l S
-38.97 336.10 m 148.04 336.10 l S
+38.97 336.09 m 148.04 336.09 l S
38.97 390.53 m 148.04 390.53 l S
38.97 444.97 m 148.04 444.97 l S
0.000 0.000 0.000 RG
@@ -169,7 +169,7 @@
54.43 64.20 l
54.53 64.21 l
54.63 64.22 l
-54.73 64.23 l
+54.73 64.24 l
54.83 64.25 l
54.94 64.26 l
55.04 64.28 l
@@ -275,7 +275,7 @@
65.15 74.45 l
65.25 74.75 l
65.35 75.05 l
-65.45 75.36 l
+65.45 75.37 l
65.55 75.68 l
65.65 76.01 l
65.75 76.34 l
@@ -320,7 +320,7 @@
69.70 96.85 l
69.80 97.61 l
69.90 98.39 l
-70.00 99.17 l
+70.00 99.18 l
70.10 99.98 l
70.20 100.79 l
70.30 101.62 l
@@ -351,15 +351,15 @@
72.83 127.42 l
72.93 128.67 l
73.03 129.93 l
-73.13 131.22 l
-73.23 132.51 l
+73.13 131.21 l
+73.23 132.52 l
73.34 133.83 l
73.44 135.17 l
73.54 136.52 l
73.64 137.89 l
73.74 139.28 l
73.84 140.68 l
-73.94 142.10 l
+73.94 142.11 l
74.04 143.55 l
74.14 145.00 l
74.25 146.48 l
@@ -380,9 +380,9 @@
75.76 170.77 l
75.86 172.53 l
75.96 174.31 l
-76.06 176.10 l
+76.06 176.11 l
76.17 177.92 l
-76.27 179.75 l
+76.27 179.74 l
76.37 181.59 l
76.47 183.45 l
76.57 185.33 l
@@ -401,13 +401,13 @@
77.88 211.18 l
77.99 213.27 l
78.09 215.38 l
-78.19 217.49 l
+78.19 217.50 l
78.29 219.63 l
78.39 221.77 l
78.49 223.93 l
78.59 226.10 l
78.69 228.28 l
-78.79 230.47 l
+78.79 230.48 l
78.90 232.68 l
79.00 234.90 l
79.10 237.12 l
@@ -416,11 +416,11 @@
79.40 243.87 l
79.50 246.13 l
79.60 248.41 l
-79.70 250.69 l
+79.70 250.70 l
79.81 252.99 l
79.91 255.29 l
80.01 257.60 l
-80.11 259.91 l
+80.11 259.92 l
80.21 262.24 l
80.31 264.57 l
80.41 266.90 l
@@ -437,13 +437,13 @@
81.52 292.87 l
81.63 295.25 l
81.73 297.62 l
-81.83 299.99 l
+81.83 300.00 l
81.93 302.37 l
82.03 304.74 l
82.13 307.11 l
82.23 309.48 l
82.33 311.84 l
-82.43 314.20 l
+82.43 314.21 l
82.54 316.56 l
82.64 318.92 l
82.74 321.26 l
@@ -453,7 +453,7 @@
83.14 330.60 l
83.24 332.92 l
83.34 335.23 l
-83.44 337.53 l
+83.44 337.52 l
83.55 339.82 l
83.65 342.10 l
83.75 344.37 l
@@ -469,7 +469,7 @@
84.76 366.40 l
84.86 368.52 l
84.96 370.63 l
-85.06 372.71 l
+85.06 372.72 l
85.16 374.78 l
85.26 376.84 l
85.37 378.87 l
@@ -556,7 +556,7 @@
93.55 443.69 l
93.66 443.01 l
93.76 442.29 l
-93.86 441.53 l
+93.86 441.54 l
93.96 440.74 l
94.06 439.92 l
94.16 439.06 l
@@ -583,7 +583,7 @@
96.28 413.39 l
96.39 411.84 l
96.49 410.26 l
-96.59 408.65 l
+96.59 408.66 l
96.69 407.02 l
96.79 405.37 l
96.89 403.69 l
@@ -619,11 +619,11 @@
99.92 344.06 l
100.02 341.85 l
100.13 339.63 l
-100.23 337.40 l
+100.23 337.41 l
100.33 335.17 l
100.43 332.93 l
100.53 330.68 l
-100.63 328.43 l
+100.63 328.42 l
100.73 326.16 l
100.83 323.90 l
100.93 321.63 l
@@ -631,12 +631,12 @@
101.14 317.07 l
101.24 314.79 l
101.34 312.50 l
-101.44 310.21 l
+101.44 310.22 l
101.54 307.93 l
101.64 305.63 l
101.74 303.34 l
101.84 301.05 l
-101.95 298.75 l
+101.95 298.76 l
102.05 296.46 l
102.15 294.17 l
102.25 291.88 l
@@ -649,7 +649,7 @@
102.96 275.91 l
103.06 273.64 l
103.16 271.38 l
-103.26 269.13 l
+103.26 269.12 l
103.36 266.87 l
103.46 264.63 l
103.56 262.39 l
@@ -661,7 +661,7 @@
104.17 249.11 l
104.27 246.93 l
104.37 244.75 l
-104.47 242.59 l
+104.47 242.58 l
104.57 240.43 l
104.68 238.28 l
104.78 236.14 l
@@ -669,7 +669,7 @@
104.98 231.90 l
105.08 229.80 l
105.18 227.71 l
-105.28 225.62 l
+105.28 225.63 l
105.38 223.55 l
105.48 221.50 l
105.59 219.45 l
@@ -677,10 +677,10 @@
105.79 215.40 l
105.89 213.39 l
105.99 211.40 l
-106.09 209.42 l
+106.09 209.41 l
106.19 207.45 l
106.29 205.49 l
-106.39 203.55 l
+106.39 203.56 l
106.49 201.63 l
106.60 199.72 l
106.70 197.82 l
@@ -716,7 +716,7 @@
109.73 148.09 l
109.83 146.68 l
109.93 145.29 l
-110.03 143.92 l
+110.03 143.91 l
110.13 142.56 l
110.24 141.21 l
110.34 139.89 l
@@ -756,7 +756,7 @@
113.77 103.94 l
113.87 103.13 l
113.98 102.34 l
-114.08 101.56 l
+114.08 101.55 l
114.18 100.79 l
114.28 100.03 l
114.38 99.29 l
@@ -861,7 +861,7 @@
124.39 66.88 l
124.49 66.80 l
124.59 66.72 l
-124.69 66.64 l
+124.69 66.63 l
124.79 66.56 l
124.89 66.48 l
125.00 66.40 l
@@ -1093,7 +1093,7 @@
38.97 172.78 m 34.21 172.78 l S
38.97 227.22 m 34.21 227.22 l S
38.97 281.66 m 34.21 281.66 l S
-38.97 336.10 m 34.21 336.10 l S
+38.97 336.09 m 34.21 336.09 l S
38.97 390.53 m 34.21 390.53 l S
38.97 444.97 m 34.21 444.97 l S
BT
Modified: branches/distr-2.1/pkg/distr/inst/doc/newDistributions.pdf
===================================================================
(Binary files differ)
Modified: branches/distr-2.1/pkg/distr/man/DiscreteDistribution-class.Rd
===================================================================
--- branches/distr-2.1/pkg/distr/man/DiscreteDistribution-class.Rd 2009-02-26 19:57:26 UTC (rev 405)
+++ branches/distr-2.1/pkg/distr/man/DiscreteDistribution-class.Rd 2009-02-27 18:49:27 UTC (rev 406)
@@ -138,7 +138,23 @@
Matthias Kohl \email{Matthias.Kohl at stamats.de}
}
-\note{ Working with a computer, we use a finite interval as support which carries at least mass \code{1-getdistrOption("TruncQuantile")}. }
+\note{ Working with a computer, we use a finite interval as support which
+ carries at least mass \code{1-getdistrOption("TruncQuantile")}. \cr
+
+ Also, we require that support points have distance at least
+ \code{getdistrOption("DistrResoltion")}, if this condition fails,
+ upon a suggestion by Jacob van Etten, \email{jacobvanetten at yahoo.com},
+ we use the global option \code{getdistrOption("DistrCollapse")} to
+ decide whether we use collapsing or not. If we do so, we collapse support
+ points if they are too close to each other, taking
+ the (left most) median among them as new support point which accumulates
+ all the mass of the collapsed points.
+ With \code{getdistrOption("DistrCollapse")==FALSE}, we at least collapse
+ points according to the result of \code{unique()}, and if after this
+ collapsing, the minimal distance is less than \code{getdistrOption("DistrResoltion")},
+ we throw an error. By \code{getdistrOption("DistrCollapse.Unique.Warn")},
+ we control, whether we throw a warning upon collapsing or not.
+ }
\seealso{
\code{\link{Parameter-class}}
Modified: branches/distr-2.1/pkg/distr/man/DiscreteDistribution.Rd
===================================================================
--- branches/distr-2.1/pkg/distr/man/DiscreteDistribution.Rd 2009-02-26 19:57:26 UTC (rev 405)
+++ branches/distr-2.1/pkg/distr/man/DiscreteDistribution.Rd 2009-02-27 18:49:27 UTC (rev 406)
@@ -5,10 +5,19 @@
\description{Generates an object of class \code{"DiscreteDistribution"}}
\synopsis{DiscreteDistribution(supp, prob, .withArith = FALSE, .withSim = FALSE,
- .lowerExact = TRUE, .logExact = FALSE)}
+ .lowerExact = TRUE, .logExact = FALSE,
+ .DistrCollapse = getdistrOption("DistrCollapse"),
+ .DistrCollapse.Unique.Warn =
+ getdistrOption(".DistrCollapse.Unique.Warn"),
+ .DistrResolution = getdistrOption("DistrResolution"))
+ }
\usage{
DiscreteDistribution(supp, prob, .withArith=FALSE, .withSim=FALSE,
- .lowerExact = TRUE, .logExact = FALSE)
+ .lowerExact = TRUE, .logExact = FALSE,
+ .DistrCollapse = getdistrOption("DistrCollapse"),
+ .DistrCollapse.Unique.Warn =
+ getdistrOption(".DistrCollapse.Unique.Warn"),
+ .DistrResolution = getdistrOption("DistrResolution"))
DiscreteDistribution(supp)
}
\arguments{
@@ -24,6 +33,14 @@
part is calculated exactly, avoing a ``\code{1-.}''.}
\item{.logExact}{normally not set by the user: whether in determining slots \code{d,p,q},
we make particular use of a logarithmic representation to enhance accuracy.}
+\item{.DistrCollapse}{controls whether in generating a new discrete
+ distribution, support points closer together than \code{.DistrResolution} are
+ collapsed.}
+\item{.DistrCollapse.Unique.Warn}{controls whether there is a warning
+ whenever collapsing occurs or when two points are collapsed by a call to
+ \code{unique()} (default behaviour if \code{.DistrCollapse} is \code{FALSE})}
+\item{.DistrResolution}{minimal spacing between two mass points in a discrete
+ distribution}
}
\details{
If \code{prob} is missing, all elements in \code{supp}
@@ -37,7 +54,23 @@
Matthias Kohl \email{Matthias.Kohl at stamats.de}
}
-\note{ Working with a computer, we use a finite interval as support which carries at least mass \code{1-getdistrOption("TruncQuantile")}. }
+\note{ Working with a computer, we use a finite interval as support which
+ carries at least mass \code{1-getdistrOption("TruncQuantile")}. \cr
+
+ Also, we require that support points have distance at least
+ \code{.DistrResoltion}, if this condition fails,
+ upon a suggestion by Jacob van Etten, \email{jacobvanetten at yahoo.com},
+ we use the global option \code{.DistrCollapse} to
+ decide whether we use collapsing or not. If we do so, we collapse support
+ points if they are too close to each other, taking
+ the (left most) median among them as new support point which accumulates
+ all the mass of the collapsed points.
+ With \code{.DistrCollapse==FALSE}, we at least collapse
+ points according to the result of \code{unique()}, and if after this
+ collapsing, the minimal distance is less than \code{.DistrResoltion},
+ we throw an error. By \code{.DistrCollapse.Unique.Warn},
+ we control, whether we throw a warning upon collapsing or not.
+ }
\seealso{
\code{\link{DiscreteDistribution-class}}
Modified: branches/distr-2.1/pkg/distr/man/distroptions.Rd
===================================================================
--- branches/distr-2.1/pkg/distr/man/distroptions.Rd 2009-02-26 19:57:26 UTC (rev 405)
+++ branches/distr-2.1/pkg/distr/man/distroptions.Rd 2009-02-27 18:49:27 UTC (rev 406)
@@ -14,7 +14,10 @@
\alias{withSweave}
%\alias{simplifyD}
\alias{withgaps}
+\alias{DistributionAggregate}
+\alias{DistributionAggregate.Unique.Warn}
+
\title{
functions to change the global variables of the package `distr'
}
@@ -49,7 +52,7 @@
\describe{
\item{\code{DefaultNrGridPoints}}{default number of grid points in integration, default value: \code{2^12}}
\item{\code{DistrResolution}}{minimal spacing between two mass points in a discrete distribution, default value: \code{1e-6}}
-\item{\code{DistrCollapse}}{logical; in convolving discrete distributions, shall support points
+\item{\code{DistrCollapse}}{logical; in discrete distributions, shall support points
with distance smaller than \code{DistrResolution} be collapsed; default value: \code{TRUE}}
\item{\code{TruncQuantile}}{argument for \code{q}-slot at which to truncate; also, for discrete distributions,
support is restricted to [\code{q(TruncQuantile)},\code{q(1-TruncQuantile)}], default value: \code{1e-5}}
@@ -71,6 +74,10 @@
---default \code{TRUE}}
\item{\code{simplifyD}}{ controls whether in the return value of arithmetic
operations there is a call to \code{simplifyD} or not ---default \code{TRUE}}
+\item{\code{DistrCollapse.Unique.Warn}}{controls whether there is a warning
+ whenever collapsing occurs or when two points are collapsed by a call to
+ \code{unique()} (default behaviour if \code{DistrCollapse} is \code{FALSE});
+ ---default \code{FALSE}}
}
}
\examples{
Modified: branches/distr-2.1/pkg/distr/man/internals.Rd
===================================================================
--- branches/distr-2.1/pkg/distr/man/internals.Rd 2009-02-26 19:57:26 UTC (rev 405)
+++ branches/distr-2.1/pkg/distr/man/internals.Rd 2009-02-27 18:49:27 UTC (rev 406)
@@ -54,6 +54,7 @@
\alias{.trunc.up}
\alias{.trunc.low}
\alias{.modifyqgaps}
+\alias{.DistrCollapse}
\alias{devNew}
\title{Internal functions of package distr}
@@ -123,6 +124,7 @@
.trunc.up(object, upper)
.trunc.low(object, lower)
.modifyqgaps(pfun, qfun, gaps, leftright = "left")
+.DistrCollapse(support, prob, eps = getdistrOption("DistrResolution"))
devNew(...)
}
@@ -190,6 +192,7 @@
\item{gaps,gaps1,gaps2}{matrices \code{m} with two columns,
such that \code{t(m)}, interpreted as vector, is ordered}
\item{support}{support vector of a univariate discrete distribution}
+ \item{prob}{probability vector for a univariate discrete distribution}
\item{mixDistr}{an object of class \code{UnivarDistrList}}
\item{mixCoeff}{an object of class \code{numeric}; a probability vector}
\item{pnew}{a function \code{function(q, lower.tail = TRUE, log.p = FALSE}
@@ -422,6 +425,14 @@
\item{.IssueWarn}{a list with two warnings to be issued each of which may be empty.}
\item{.fillList}{a list.}
\item{.trunc.up,.trunc.low}{a list with elements \code{r,p,d,q} (in this order).}
+\item{.DistrCollapse}{upon a suggestion by Jacob van Etten,
+ \email{jacobvanetten at yahoo.com}: help function to collapse the support
+ points of a discrete distributions if they are too close to each other;
+ here argument \code{support} is the (original; already sorted) support
+ and \code{prob} a corresponding probability vector of same length.
+ Criterium for collapsing: a distance smaller than argument
+ \code{eps}.
+ }
\item{devNew}{returns the return value of the device opened,
usually invisible \code{NULL}.}
}
More information about the Distr-commits
mailing list