Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

Truncate-methods

Methods for function Truncate in Package ‘distr’


Description

Truncate-methods

Usage

Truncate(object, ...)
## S4 method for signature 'AbscontDistribution'
Truncate(object, lower = -Inf, upper = Inf)
## S4 method for signature 'DiscreteDistribution'
Truncate(object, lower= -Inf, upper = Inf)
## S4 method for signature 'LatticeDistribution'
Truncate(object, lower= -Inf, upper = Inf)
## S4 method for signature 'UnivarLebDecDistribution'
Truncate(object, lower = -Inf, upper = Inf, 
                    withSimplify = getdistrOption("simplifyD"))

Arguments

object

distribution object

...

not yet used; takes up lower, upper, withSimplify.

lower

numeric; lower truncation point

upper

numeric; upper truncation point

withSimplify

logical; is result to be piped through a call to simplifyD?

Value

the corresponding distribution of the truncated random variable

Methods

Truncate

signature(object = "AbscontDistribution"): returns the distribution of min(upper,max(X,lower)) conditioned to lower<=X<=upper, if X is distributed according to object; if slot .logExact of argument object is TRUE and if either there is only one-sided truncation or both truncation points lie on the same side of the median, we use this representation to enhance the range of applicability, in particular, for slot r, we profit from Peter Dalgaard's clever log-tricks as indicated in http://r.789695.n4.nabble.com/help-on-sampling-from-the-truncated-normal-gamma-distribution-on-the-far-end-probability-is-very-low-td868119.html#a868120. To this end we use the internal functions (i.e.; non exported to namespace) .trunc.up and .trunc.low which provide functional slots r,d,p,q for one-sided truncation. In case of two sided truncation, we simply use one-sided truncation successively — first left and then right in case we are right of the median, and the other way round else; the result is again of class "AbscontDistribution";

Truncate

signature(object = "DiscreteDistribution"): returns the distribution of min(upper,max(X,lower)) conditioned to lower<=X<=upper, if X is distributed according to object; the result is again of class "DiscreteDistribution"

Truncate

signature(object = "LatticeDistribution"): if length of the corresp. lattice is infinite and slot .logExact of argument object is TRUE, we proceed similarly as in case of AbscontDistribution, also using internal functions .trunc.up and .trunc.low; else we use the corresponding "DiscreteDistribution" method; the result is again of class "LatticeDistribution"

Truncate

signature(object = "UnivarLebDecDistribution"): returns the distribution of min(upper,max(X,lower)) conditioned to lower<=X<=upper, if X is distributed according to object; the result is again of class "UnivarLebDecDistribution"

See Also

Examples

plot(Truncate(Norm(),lower=-1,upper=2))
TN <- Truncate(Norm(),lower=15,upper=15.7) ### remarkably right!
plot(TN)
r(TN)(30)
TNG <- Truncate(Geom(prob=0.05),lower=325,upper=329) ### remarkably right!
plot(TNG)

distr

Object Oriented Implementation of Distributions

v2.8.0
LGPL-3
Authors
Florian Camphausen [ctb] (contributed as student in the initial phase --2005), Matthias Kohl [aut, cph], Peter Ruckdeschel [cre, cph], Thomas Stabla [ctb] (contributed as student in the initial phase --2005), R Core Team [ctb, cph] (for source file ks.c/ routines 'pKS2' and 'pKolmogorov2x')
Initial release
2019-03-11

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.