Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm assuming these events are independent. Here's one way to generate a table of the joint PMF.</p> <p>First, here are the names you've defined, along with the lambdas:</p> <pre><code>name &lt;- c("0","1","2","3","4","5","6","7+") lambda1 &lt;- 1.5 lambda2 &lt;- 1.25 </code></pre> <p>We can get the marginal probabilities for 0-6 by using <code>dpois</code>, and the marginal probability for 7+ using <code>ppois</code> and <code>lower.tail=FALSE</code>:</p> <pre><code>p.x &lt;- c(dpois(0:6, lambda1), ppois(7, lambda1, lower.tail=FALSE)) p.y &lt;- c(dpois(0:6, lambda2), ppois(7, lambda2, lower.tail=FALSE)) </code></pre> <p>An even better way might be to create a function that does this given any lambda.</p> <p>Then you just take the outer product (really, the same thing you would do by hand, outside of R) and set the names:</p> <pre><code>p.xy &lt;- outer(p.x, p.y) rownames(p.xy) &lt;- colnames(p.xy) &lt;- name </code></pre> <p>Now you're done:</p> <pre><code> 0 1 2 3 4 5 0 6.392786e-02 7.990983e-02 4.994364e-02 2.080985e-02 6.503078e-03 1.625770e-03 1 9.589179e-02 1.198647e-01 7.491546e-02 3.121478e-02 9.754617e-03 2.438654e-03 2 7.191884e-02 8.989855e-02 5.618660e-02 2.341108e-02 7.315963e-03 1.828991e-03 3 3.595942e-02 4.494928e-02 2.809330e-02 1.170554e-02 3.657982e-03 9.144954e-04 4 1.348478e-02 1.685598e-02 1.053499e-02 4.389578e-03 1.371743e-03 3.429358e-04 5 4.045435e-03 5.056794e-03 3.160496e-03 1.316873e-03 4.115229e-04 1.028807e-04 6 1.011359e-03 1.264198e-03 7.901240e-04 3.292183e-04 1.028807e-04 2.572018e-05 7+ 4.858139e-05 6.072674e-05 3.795421e-05 1.581426e-05 4.941955e-06 1.235489e-06 6 7+ 0 3.387020e-04 1.094781e-05 1 5.080530e-04 1.642171e-05 2 3.810397e-04 1.231628e-05 3 1.905199e-04 6.158140e-06 4 7.144495e-05 2.309303e-06 5 2.143349e-05 6.927908e-07 6 5.358371e-06 1.731977e-07 7+ 2.573935e-07 8.319685e-09 </code></pre> <p>You could have also used a loop, as you originally suspected, but that's a more roundabout way to the same solution.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload