Reputation: 51
How would I convert the following formula to php to solve for "p":
(1-p)^365=.80
What I'm trying to do is calculate the daily probability of an event based on the annual probability. For example, let's say the likelihood that John Doe is going to die in a particular year is 20%. So what would be the likelihood on any given day of that year? I know the answer for that example scenario is 0.0611165 using the formula above (where .80 is the 80% annual survival probability). What I need is a formula in which I can substitute various annual probabilities and the result would be the corresponding daily probabilities.
Can anyone help?
Upvotes: 0
Views: 433
Reputation: 2626
To solve for p
you need to take the 365-th root of both sides, then solve for p
.
<?php
$prob = 0.80;
$p = 1 - pow($prob, 1/365);
?>
Upvotes: 1
Reputation: 7086
Well you'd take the 365th root of both sides which is equivalent to raising to the 1/365
<?php
$prob = 0.80;
$prob = pow($prob, 1/365);
then you'd add 1
$p = $prob + 1;
echo $p;
?>
Upvotes: 0