0

I have a set of Bernoulli variables, giving specific values with different probabilities. The variables are independent. I'm trying to build a simple discrete probability table for all the possible outcomes. A short example of the data I have is:

# A tibble: 2 x 4
  `test number`  prob value `no-value`
          <dbl> <dbl> <dbl>      <dbl>
1             1   0.7   1.7        0.3
2             2   0.6   1.5        0.6

and the solution I'm trying to find is:

# A tibble: 1 x 5
  value       `3.2` `2.299999999999999~ `1.8` `0.8999999999999999~
  <chr>       <dbl>               <dbl> <dbl>                <dbl>
1 probability  0.42               0.280  0.18                 0.12

Where the value is the sum of the possible values and the probability is the probability of this value.

The example I'm using is from an excel sheet. The table I'm working on is a long list of independent tests. Each test has a possible value for success, a probability for success and a value for no success (with 1 - probability for failure). The probability table is a table that calculates the probability for each possible outcome - possible values (summing the values for that outcome) and the probability for that outcome. So the first possible outcome 3.2 = 1.7 + 1.5 has a probability of 0.42 = 0.7 * 0.6. The second outcome is 2.3 = (1.7 + 0.6) with a probability of 0.28 = (0.7 * (1 - 0.6) and so on.

Amidavid
  • 177
  • 7
  • 2
    where do you get 0.42 from? or even 0.280 from? – Onyambu Nov 18 '19 at 15:55
  • 2
    This isn't very clear. Please give a reproducible input and the corresponding expected output. See [How to make a great R reproducible example?](https://stackoverflow.com/q/5963269/4996248) for tips on what this means. – John Coleman Nov 18 '19 at 16:00
  • Doesn't make much sense to me. In R, the Bernoulli distribution is just a special case of `*binom` with `*` equal to any of `dpqr`. – Rui Barradas Nov 18 '19 at 16:08
  • Do you mean pbinom() or dbinom()? these are functions that are related to the Bernoulli dist, that could be used as directed above. – Hansel Palencia Nov 18 '19 at 16:14
  • Sorry for the unclear comment. @Onyambu , the example I'm using is from an excel sheet. The table I'm working on is a long list of independent tests. Each test has a possible value for success, a probability for success and a value for no success (with 1 - probability for failure). The probability table is a table that calculates the probability for each possible outcome - possible values (summing the values for that outcome) and the probability for that outcome. So the first possible outcome 3.2 = 1.7 + 1.5 has a probability of 0.42 = 0.7 * 0.6. – Amidavid Nov 19 '19 at 08:16

0 Answers0