I'd very much appreciate a solution to the following problem. I should point out that I'm not a student and this problem has NOT been presented to me as some form of test, but rather has occurred as a consequence of a much larger system I've been working on.

On with the problem...

At set intervals (for example every minute) a test is performed to see if a patient has deteriorated or stabilised. These two outcomes are mutually exclusive, in that a patient cannot both deteriorate AND stabilise at the same interval.

Once a patient stabilises they can no longer deteriorate, and therefore no more tests will need to be performed.

If a patient deteriorates a certain number of times before stabilising then the patient will expire, and no more tests will need to be performed.

For consistency represent the probability of a patient deteriorating at a given interval as 'd', and the probability of a patient stabilising at a given interval as 's'. Also the patient will expire/die after 'x' deteriorations.

The questions I'd very much appreciate answers to are as follows:

1. What is the probability of patient death after 'n' intervals?

2. What is the probability of patient stabilisation (and therefore not death) after 'n' intervals?

3. What is the probability of a patient still being alive after 'n' intervals, having NOT yet stabilised?

1, 2 and 3 should add up to 1. Where n is less than x, 1 should be zero.

I have written a computer program to simulate and sample this problem and give increasingly accurate approximations as sample size increases. However I'd very much appreciate an exact algebraic solution. The benefit to having such a program is that any alegraic solution can be compared to the approximate data from the simulation.

Thank you very much for taking the time to read this problem, and I look forward to your responses.

All the best,

James

## Patient Probability Problem

**Moderators:** gmalivuk, Moderators General, Prelates

- Xanthir
- My HERO!!!
**Posts:**5336**Joined:**Tue Feb 20, 2007 12:49 am UTC**Location:**The Googleplex-
**Contact:**

### Re: Patient Probability Problem

It sounds like there's a third "no change" outcome to the test? Otherwise the answer to the third question is trivial; 100% chance they're alive if N is less than X, 0% chance if N is greater than or equal to X.

Are D and S out of the same interval, or separate? That is, is the math that (D + S + (no change) = 100%) or is there a D chance of deteriorating, then if they don't deteriorate, an S chance of stabilizing, such that the equation is (D + (1-D)(S + no change) = 100%)?

I think the exact algebraic solutions are messy inclusion-exclusion products.

Are D and S out of the same interval, or separate? That is, is the math that (D + S + (no change) = 100%) or is there a D chance of deteriorating, then if they don't deteriorate, an S chance of stabilizing, such that the equation is (D + (1-D)(S + no change) = 100%)?

I think the exact algebraic solutions are messy inclusion-exclusion products.

(defun fibs (n &optional (a 1) (b 1)) (take n (unfold '+ a b)))

### Re: Patient Probability Problem

Many thanks for the response.

At each interval there are 3 outcomes; deterioration, stabilisation or neither. I'm sorry, I felt that a neither outcome was implied, since s and d are probabilities 0 to 1, unless of course s or d were 1.

I stated that for n less than x the chance of death was zero. However the chance cannot be zero for n greater than x because they can deteriorate to death before stabilisation. The only possible 0% outcome would be if s or d were 0. However, the problem is not about specific s or d, but rather about finding algebraic solutions for ANY s, d, x or n.

You raise an important point about the nature of how s and d are tested. I should have been clearer on that, I'm sorry. s and d are tested at the same time, in that s + d <= 1. So I can use the p <= d for a deterioration OR p > 1 - s test for stabilisation. So your former statement was correct D + S + (no change) = 1.

I suspect you are right about it being messy, but I hoped one of you maths/stats bods here might have a neat-ish solution. Any algebraic solution, messy or not, beats running million+ computer samples.

At each interval there are 3 outcomes; deterioration, stabilisation or neither. I'm sorry, I felt that a neither outcome was implied, since s and d are probabilities 0 to 1, unless of course s or d were 1.

I stated that for n less than x the chance of death was zero. However the chance cannot be zero for n greater than x because they can deteriorate to death before stabilisation. The only possible 0% outcome would be if s or d were 0. However, the problem is not about specific s or d, but rather about finding algebraic solutions for ANY s, d, x or n.

You raise an important point about the nature of how s and d are tested. I should have been clearer on that, I'm sorry. s and d are tested at the same time, in that s + d <= 1. So I can use the p <= d for a deterioration OR p > 1 - s test for stabilisation. So your former statement was correct D + S + (no change) = 1.

I suspect you are right about it being messy, but I hoped one of you maths/stats bods here might have a neat-ish solution. Any algebraic solution, messy or not, beats running million+ computer samples.

- Xanthir
- My HERO!!!
**Posts:**5336**Joined:**Tue Feb 20, 2007 12:49 am UTC**Location:**The Googleplex-
**Contact:**

### Re: Patient Probability Problem

I'll disagree with you there - a million simulation trials, conducted naively, only takes a second or so, and is really easy to code. Figuring out the algebra can be a lot more difficult, and depending on how the math turns out and how naively it's coded, might end up doing silly things like generating massive factorials that mostly cancel out.

Simulation is great!

Simulation is great!

(defun fibs (n &optional (a 1) (b 1)) (take n (unfold '+ a b)))

### Re: Patient Probability Problem

Don't get me wrong, writing the simulation was dead easy and gave me the results very quickly. I write simulators for everything.

However I just love to have the exact algebra, that I can use immediately without the need to code. Also I get to learn something in the process.

There was a time, back in the good old bad old days when micros at home had very little power to run simulations. Not so anymore.

Obviously I don't wish anyone to go off and try to solve the 4-colour theorem or Fermat's last conjecture

However I just love to have the exact algebra, that I can use immediately without the need to code. Also I get to learn something in the process.

There was a time, back in the good old bad old days when micros at home had very little power to run simulations. Not so anymore.

Obviously I don't wish anyone to go off and try to solve the 4-colour theorem or Fermat's last conjecture

### Re: Patient Probability Problem

Question for people who haven't forgotten most what they knew about statistics: I think that for large n you could assume that (no change)% of n are unimportant and then normalize d and s so they are the only possibilities for the other (1-no change)*n evaluations. Does that make sense? (Not that it is useful her, n is probably too small and if you use a pc you don't need an approximation, I am just wondering whether the though itself makes some sense.)

Anyway this is tricky without the no change option it would basically be https://en.wikipedia.org/wiki/Martingale_(betting_system) with stabilizing= winning and doubling until you run out of money = too many deterioration. But with no change I am not sure how to calculate it without much summing, hmm.

Anyway this is tricky without the no change option it would basically be https://en.wikipedia.org/wiki/Martingale_(betting_system) with stabilizing= winning and doubling until you run out of money = too many deterioration. But with no change I am not sure how to calculate it without much summing, hmm.

### Re: Patient Probability Problem

I feel like you could do induction on x and use generating functions.

I started writing a potential solution, but due to writing it on a phone, confused myself. I was originally going to use induction, but then tricked myself into not.

I believe generating functions are the natural way to solve Markov Chain problems (especially ones with such regularity).

This link should be useful, but I have confused myself into not being able to explain why.

I started writing a potential solution, but due to writing it on a phone, confused myself. I was originally going to use induction, but then tricked myself into not.

**Spoiler:**

I believe generating functions are the natural way to solve Markov Chain problems (especially ones with such regularity).

This link should be useful, but I have confused myself into not being able to explain why.

### Who is online

Users browsing this forum: No registered users and 6 guests