File: ARITHMETICS

package info (click to toggle)
r-cran-distr 2.9.7%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,344 kB
  • sloc: ansic: 199; sh: 13; makefile: 2
file content (74 lines) | stat: -rw-r--r-- 3,035 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
######################################################################
#  On arithmetics operating on distributions in package "distr"       
######################################################################


                      Attention:

Special caution is due in the followin issues

%--------------------------------------------------------------------
% Interpretation of arithmetics
%--------------------------------------------------------------------

Arithmetics on distribution objects are understood as operations on 
corresponding random variables (r.v.'s) and _not_ on distribution 
functions or densities; 
e.g.

    sin( Norm() + 3 * Norm() ) + 2
    
returns a distribution object representing the distribution of the r.v. 

     sin(X+3*Y)+2
     
where X and Y are r.v.'s i.i.d. N(0,1).

%--------------------------------------------------------------------
% Adjusting accuracy
%--------------------------------------------------------------------

Binary operators like "+", "-" would loose their elegant calling
 e1 + e2 if they had to be called with an extra argument controlling
their accuracy. Therefore, this accuracy is controlled by global options.
These options are inspected and set by distroptions(), getdistrOption(),
see ?distroptions

%--------------------------------------------------------------------
% Multiple instances in expressions and independence
%--------------------------------------------------------------------

Special attention has to be paid to arithmetic expressions of
distributions involving multiple instances of the same symbol:

/-> All arising instances of distribution objects in arithmetic
    expressions are assumed stochastically independent. <-/

As a consequence, whenever in an expression, the same symbol for 
an object occurs more than once, every instance means a new 
independent distribution.  

So for a distribution object X, the expressions X+X and 2*X are _not_
equivalent. 

The first means the convolution of distribution X with distribution 
X, i.e. the distribution of the r.v. X1 + X2, where X1 and X2 are 
identically distributed according to X. 
In contrast to this, the second expression means the distribution of 
the r.v. 2 X1 = X1 + X1, where again X1 is distributed according to X.

Hence always use 2*X, when you want to realize the second case.

Similar caution is due for X^2 and X*X and so on.

%--------------------------------------------------------------------
% Simulation based results varying from call to call
%--------------------------------------------------------------------

At several instances (in particular for non-monotone functions from group
 Math like sin(), cos()) new distributions are generated by means of 
RtoDPQ, RtoDPQ.d, RtoDPQ.LC. In these functions, slots d, p, q are 
filled by simulating a large number of random variables, hence they are 
stochastic estimates. 

So don't be surprised if they will change from call to call.