probability-discrete.rst
author Oleksandr Gavenko <gavenkoa@gmail.com>
Fri, 18 Mar 2016 20:42:18 +0200
changeset 7 c9c0861c10c2
parent 5 60353d4d994d
child 9 d4bed13a2c37
permissions -rw-r--r--
Linear function of distribution. Monotonic function of distribution.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     1
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     2
=============
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     3
 Probability
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     4
=============
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     5
.. contents::
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     6
   :local:
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     7
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     8
.. role:: def
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     9
   :class: def
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    10
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    11
PMF
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    12
===
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    13
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    14
:def:`PMF` or :def:`probability mass function` or :def:`probability law` or
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    15
:def:`probability discribuion` of discrete random variable is a function that
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    16
for given number give probability of that value.
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    17
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    18
To denote PMF used notations:
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    19
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    20
.. math::
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    21
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    22
   PMF(X = x) = P(X = x) = p_X(x) = P({ω ∈ Ω: X(ω) = x})
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    23
5
60353d4d994d PMF properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 0
diff changeset
    24
   PMF(a ≤ X ≤ b) = P(a ≤ X ≤ b) = ∑_{a ≤ x ≤ b} P(X = x)
60353d4d994d PMF properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 0
diff changeset
    25
60353d4d994d PMF properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 0
diff changeset
    26
   p_X(x) ≥ 0
60353d4d994d PMF properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 0
diff changeset
    27
60353d4d994d PMF properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 0
diff changeset
    28
   ∑_x p_X(x) = 1
60353d4d994d PMF properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 0
diff changeset
    29
0
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    30
where :math:`X` is a random variable on space :math:`Ω` of outcomes which mapped
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    31
to real number via :math:`X(ω)`.
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    32
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    33
Expected value
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    34
==============
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    35
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    36
:def:`Expected value` of PMF is:
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    37
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    38
.. math::
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    39
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    40
  E[X] = Σ_{ω∈Ω} Χ(x) * p(ω) = Σ_{x} x * p_X(x)
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    41
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    42
We write :math:`a ≤ X ≤ b` for :math:`∀ ω∈Ω a ≤ X(ω) ≤ b`.
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    43
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    44
If :math:`X ≥ 0` then :math:`E[X] ≥ 0`.
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    45
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    46
if :math:`a ≤ X ≤ b` then :math:`a ≤ E[X] ≤ b`.
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    47
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    48
If :math:`Y = g(X)` (:math:`∀ ω∈Ω Y(ω) = g(X(ω))`) then:
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    49
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    50
.. math::
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    51
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    52
  E[Y] = Σ_{x} g(x) * p_X(x)
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    53
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    54
**Proof** TODO:
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    55
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    56
.. math::
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    57
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    58
  E[Y] = Σ_{y} y * p_Y(y)
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    59
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    60
  = Σ_{y∈ℝ} y * Σ_{ω∈Ω: Y(ω)=y} p(ω)
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    61
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    62
  = Σ_{y∈ℝ} y * Σ_{ω∈Ω: g(X(ω))=y} p(ω)
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    63
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    64
  = Σ_{y∈ℝ} y * Σ_{x∈ℝ: g(x)=y} Σ_{ω∈Ω: X(ω) = x} p(ω)
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    65
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    66
  = Σ_{y∈ℝ} y * Σ_{x∈ℝ: g(x)=y} p_X(x)
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    67
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    68
  = Σ_{y∈ℝ} Σ_{x∈ℝ: g(x)=y} y * p_X(x)
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    69
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    70
  = Σ_{x∈ℝ} Σ_{y∈ℝ: g(x)=y} y * p_X(x)
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    71
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    72
  = Σ_{x} g(x) * p_X(x)
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    73
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    74
.. math::
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    75
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    76
  E[a*X + b] = a*E[X] + b
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    77
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    78
Variance
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    79
========
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    80
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    81
:def:`Variance` is a:
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    82
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    83
.. math::
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    84
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    85
  var[X] = E[(X - E[X])^2] = E[X^2] - E^2[X]
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    86
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    87
:def:`Standard deviation` is a:
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    88
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    89
.. math::
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    90
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    91
  σ_Χ = sqrt(var[X])
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    92
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    93
Property:
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    94
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    95
.. math::
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    96
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    97
  var(a*X + b) = a²̇ · var[X]
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    98
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    99
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   100
Total probability theorem
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   101
=========================
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   102
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   103
Let :math:`A_i ∩ A_j = ∅` for :math:`i ≠ j` and :math:`∑_i A_i = Ω`:
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   104
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   105
.. math::
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   106
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   107
  p_X(x) = Σ_i P(A_i)·p_{X|A_i}(x)
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   108
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   109
Conditional PMF
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   110
===============
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   111
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   112
:def:`Conditional PMF` is:
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   113
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   114
.. math::
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   115
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   116
  p_{X|A}(x) = P(X=x | A)
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   117
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   118
  E[X|A] = ∑_x x·p_{X|A}(x)
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   119
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   120
Total expectation theorem
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   121
=========================
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   122
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   123
.. math::
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   124
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   125
  E[X] = Σ_i P(A_i)·E[X|A_i]
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   126
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   127
To prove theorem just multiply total probability theorem by :math:`x`.
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   128
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   129
Joint PMF
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   130
=========
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   131
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   132
:def:`Joint PMF` of random variables :math:`X_1,...,X_n` is:
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   133
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   134
.. math::
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   135
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   136
   p_{X_1,...,X_n}(x_1,...,x_n) = P(AND_{x_1,...,x_n}: X_i = x_i)
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   137
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   138
Properties:
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   139
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   140
.. math::
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   141
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   142
  E[X+Y] = E[X] + E[Y]
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   143
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   144
Conditional PMF
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   145
===============
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   146
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   147
:def:`Conditional PMF` is:
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   148
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   149
.. math::
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   150
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   151
  p_{X|Y}(x|y) = P(X=x | Y=y) = P(X=x \& Y=y) / P(Y=y)
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   152
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   153
So:
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   154
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   155
.. math::
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   156
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   157
  p_{X,Y}(x,y) = p_Y(y)·p_{X|Y}(x|y) = p_X(x)·p_{Y|X}(y|x)
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   158
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   159
  p_{X,Y,Z}(x,y,z) = p_Y(y)·p_{Z|Y}(z|y)·p_{X|Y,Z}(x|y,z)
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   160
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   161
  ∑_{x,y} p_{X,Y|Z}(x,y|z) = 1
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   162
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   163
Conditional expectation of joint PMF
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   164
====================================
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   165
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   166
:def:`Conditional expectation of joint PMF` is:
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   167
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   168
.. math::
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   169
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   170
  E[X|Y=y] = ∑_x x·p_{X|Y}(x|y)
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   171
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   172
  E[g(X)|Y=y] = ∑_x g(x)·p_{X|Y}(x|y)
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   173
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   174
Total probability theorem for joint PMF
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   175
=======================================
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   176
.. math::
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   177
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   178
  p_X(x) = ∑_y p_Y(y)·p_{X|Y}(x|y)
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   179
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   180
Total expectation theorem for joint PMF
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   181
=======================================
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   182
.. math::
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   183
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   184
  E[X] = ∑_y p_Y(y)·E[X|Y=y]
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   185
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   186
Independence of r.v.
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   187
====================
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   188
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   189
r.v. :math:`X` and :math:`Y` is :def:`independent` if:
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   190
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   191
.. math::
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   192
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   193
  ∀_{x,y}: p_{X,Y}(x,y) = p_X(x)·p_Y(y)
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   194
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   195
So if two r.v. are independent:
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   196
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   197
.. math::
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   198
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   199
  E[X·Y] = E[X]·E[Y]
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   200
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   201
  var(X+Y) = var(X) + var(Y)
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   202
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   203
Well known discrete r.v.
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   204
========================
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   205
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   206
Bernoulli random variable
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   207
-------------------------
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   208
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   209
:def:`Bernoulli random variable` with parameter :math:`p` is a random variable
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   210
that have 2 outcomes denoted as :math:`0` and :math:`1` with probabilities:
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   211
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   212
.. math::
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   213
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   214
  p_X(0) = 1 - p
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   215
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   216
  p_X(1) = p
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   217
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   218
This random variable models a trial of experiment that result in success or
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   219
failure.
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   220
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   221
:def:`Indicator` of r.v. event :math:`A` is function::
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   222
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   223
   I_A = 1 iff A occurs, else 0
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   224
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   225
.. math::
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   226
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   227
  P_{I_A} = p(I_A = 1) = p(A)
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   228
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   229
  I_A*I_B = I_{A∩B}
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   230
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   231
.. math::
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   232
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   233
  E[bernoulli(p)] = 0*(1-p) + 1*p = p
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   234
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   235
  var[bernoulli(p)] = E[bernoulli(p) - E[bernoulli(p)]]
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   236
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   237
   = (0-p)²·(1-p) + (1-p)²·p = p²·(1-p) + (1 - 2p + p²)·p
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   238
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   239
   = p² - p³ + p - 2·p² + p³ = p·(1-p)
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   240
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   241
Discret uniform random variable
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   242
-------------------------------
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   243
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   244
:def:`Discret uniform random variable` is a variable with parameters :math:`a`
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   245
and :math:`b` in sample space :math:`{x: a ≤ x ≤ b & x ∈ ℕ}` with equal
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   246
probability of each possible outcome:
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   247
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   248
.. math::
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   249
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   250
  p_{unif(a,b)}(x) = 1 / (b-a+1)
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   251
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   252
.. math::
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   253
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   254
  E[unif(a,b)] = Σ_{a ≤ x ≤ b} x * 1/(b-a+1)
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   255
  = 1/(b-a+1) * Σ_{a ≤ x ≤ b} x
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   256
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   257
  = 1/(b-a+1) * (Σ_{a ≤ x ≤ b} a + Σ_{0 ≤ x ≤ b-a} x)
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   258
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   259
  = 1/(b-a+1) * ((b-a+1)*a + (b-a)*(b-a+1)/2)
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   260
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   261
  = a + (b-a)/2
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   262
  = (b+a)/2
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   263
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   264
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   265
.. math::
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   266
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   267
  var[unif(a,b)] = E[unif²(a,b)] - E²[unif(a,b)]
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   268
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   269
  = ∑_{a≤x≤b} x²/(b-a+1) - (b+a)²/4
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   270
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   271
  = 1/(b-a+1)·(∑_{0≤x≤b} x² - ∑_{0≤x≤a-1} x²) - (b+a)²/4
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   272
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   273
  = 1/(b-a+1)·(b+3·b²+2·b³ - (a-1)+3·(a-1)²+2·(a-1)³)/6 - (b+a)²/4
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   274
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   275
  = (2·b² + 2·a·b + b + 2·a² - a)/6 - (b+a)²/4
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   276
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   277
  = (b - a)·(b - a + 2) / 12
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   278
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   279
.. NOTE::
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   280
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   281
   From Maxima::
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   282
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   283
     sum(i^2,i,0,n), simpsum=true;
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   284
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   285
              2      3
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   286
       n + 3 n  + 2 n
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   287
       ---------------
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   288
             6
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   289
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   290
     factor(b+3*b^2+2*b^3 - (a-1)-3*(a-1)^2-2*(a-1)^3);
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   291
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   292
                       2                  2
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   293
       (b - a + 1) (2 b  + 2 a b + b + 2 a  - a)
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   294
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   295
     factor((2*b^2 + 2*a*b + b + 2*a^2 - a)/6 - (b+a)^2/4), simp=true;
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   296
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   297
       (b - a) (2 - a + b)
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   298
       -------------------
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   299
               12
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   300
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   301
Binomial random variable
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   302
------------------------
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   303
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   304
:math:`Binomial random variable` is a r.v. with parameters :math:`n` (positive
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   305
integer) and p from interval :math:`(0,1)` and sample space of positive integers
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   306
from inclusive region :math:`[0, n]`:
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   307
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   308
.. math::
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   309
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   310
  p_{binom(n,p)}(x) = n!/(x!*(n-x)!) p^x p^{n-x}
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   311
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   312
Binomial random variable models a number of success of :math:`n` independent
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   313
trails of Bernoulli experimants.
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   314
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   315
.. math::
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   316
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   317
  E[binom(n,p)] = E[∑_{1≤x≤n} bernoulli(p)] = ∑_{1≤x≤n} E[bernoulli(p)] = n·p
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   318
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   319
  var[binom(n,p)] = var[∑_{1≤x≤n} bernoulli(p)] = ∑_{1≤x≤n} var[bernoulli(p)] = n·p·(1-p)
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   320
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   321
Geometric random variable
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   322
-------------------------
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   323
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   324
:def:`Geometric random variable` is a r.v. with parameter :math:`p` from
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   325
half open interval :math:`(0,1]`, sample space is all positive numbers:
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   326
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   327
.. math::
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   328
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   329
  p_{geom(p)}(x) = p (1-p)^(x-1)
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   330
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   331
This random variable models number of tosses of biased coin until first success.
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   332
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   333
.. math::
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   334
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   335
  E[geom(p)] = ∑_{x=1..∞} x·p·(1-p)^(x-1)
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   336
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   337
  = p·∑_{x=1..∞} x·(1-p)^(x-1)
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   338
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   339
  = p/(1-p)·∑_{x=0..∞} x·(1-p)^x
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   340
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   341
  = p/(1-p)·(1-p)/(1-p - 1)² = p/p² = 1/p
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   342
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   343
.. NOTE::
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   344
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   345
   Maxima calculation::
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   346
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   347
     load("simplify_sum");
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   348
     simplify_sum(sum(k * x^k, k, 0, inf));
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   349
       Is abs(x) - 1 positive, negative or zero?
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   350
       negative;
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   351
       Is x positive, negative or zero?
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   352
       positive;
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   353
       Is x - 1 positive, negative or zero?
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   354
       negative;
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   355
            x
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   356
       ------------
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   357
        2
328995b5b8fd init stat project
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   358
       x  - 2 x + 1