# Modeling a process with decay and refilling

My question is about the approach that needs to be taken for modeling a particular process with . I have looked around for similar questions or answers but didn't find any. I got some links to Markov arrival processes and Batch-Markov-Processes, but they don't fit the problem I have completely. I am still trying to wrap my head around the problem, so please pardon my explanation if it is not clear. I hope I'll even get the question more precise and meaningful as I get some questions on it.

The process is as follows.

1. We start off with an initial quantity of an decaying material in a box.
2. The material keeps decaying at a particular rate per hour and vanishes.
3. When we see that the quantity has fallen below particular amount (unknown, but the smaller the amount the higher the chance of repopulating) we'd repopulate (or restock) the box with more.

Now, some external observer gets to look at the box with the material every few hours and makes measurements $X_1$ ... $X_n$. The question I have is, is there a way to estimate which $X_i$ come out as a result of repopulating/refilling.

For instance, in the simplest edge-case someone observed:

10, 9, 8, 7, 6, 5, 4, 13, 12, 11, 8, 6, 11, 29, ...

We know that the restocking happened at position 8 (4->13) and at position 12 (6->11).

The simple heuristic of compare with previous value and if there is an increase then restocking happened, otherwise not, would work to some extent - but the point is, when a user observes the "box" and notes down the quantity, it is possible that a restocking and a large amount of decay has happened in that interval. The only way to find that out would be to know something about the rate-of-decay estimated and the events of refilling identified.

Edit 1:

We can write $X_{t+1} = X_t - \alpha_t + \beta_t$. Where $\alpha_t$ is a poisson random variable with rate $\lambda$ and $\beta_t$ is something that is random too, and takes values of either 0, or something very large (like refilling the box). This $\beta_t$ taking large value is triggered by $X_t$ being low.

I forgot to mention, I tried mixture of poissons, but the problem there is that the decay-process is modeled by one poisson, and the refill process by another poisson, i.e its either this or that - however, there are cases were some observations are a combination of both which the mixture didn't help modeling (one can use the soft-memberships in the mixture-model to infer this, but fundamentally the model itself assumes that the observation $X_t$ comes from one of the distributions, which seems to be not true in my case.

Edit 2:

Here is some more difficult data! Thanks!

16, 5, 5, 1, 2, 3, 4, 4, 11, 1, 22, 5, 2, 2, 1, 2, 2, 22, 1, 6, 1, 4, 1, 11, 1, 2, 3, 1

• When you say it decays at a particular rate per hour, are you losing material at a fixed proportion per hour (like say $5\%$ per hour, like radioactive decay) or at a fixed amount (say $5l$ per hour, like water being pumped out of a tank). Your words seem to suggest the first, but your numbers suggest the second. – Glen_b Dec 12 '14 at 8:58
• Is there any noise in this process? – Glen_b Dec 12 '14 at 9:16
• @Glen_b The decay is not fixed like 5% per hour. The exact decay is probabilistic in nature. I didn't know exactly how to model the probability, so I gave an example. Think of it like a poisson process. – user1669710 Dec 12 '14 at 17:09
• Wait, so the data are all counts? Your initial discussion used words like "quantity", which suggested "amounts of stuff" rather than counts to me. – Glen_b Dec 12 '14 at 20:58
• Do you have some more difficult data? Oh, and do you have at least some data for which you know for certain when the restocking times were? – Glen_b Dec 12 '14 at 21:01

Part 1 - simple discussion: Let's look at the differences of the data $X_t-X_{t-1}$; if the normal decay is a constant amount per unit time it will show up as a horizontal negative line, while restocking should show either as positive (or at least, if negative, as nearer to zero than the flat decay line). As you can see, the horizontal constant-amount decay line is obvious, a little below 0, while the restocking events are also obvious (position 8, 13 and 14).

(Note that you made a mistake with the timing of the second restock - it's one period later than you said).

There's also a short interval (11-12) where the decay seems to be faster than the previously experienced constant-amount.

Some more details about the circumstances would help with saying more. If your real data are like this, you could write some fairly simple rules for deciding where the restocking occurs. If things are often much more complicated, more details will be needed to figure out more.

For example, if substantial noise in the decay rate is possible, it may be difficult to detect the difference between constant-amount-decay-with-noise and restock+large-decay.

Part 2 - building a model:

I think this is a good candidate for a Bayesian model. At each time point you'll end up with a probability distribution on there being a restocking event (so for example, the mean of that distribution at time $t$ - the mean chance of a restocking event at $t$ given the data - might be interesting to you as an output).

You'd start with priors on the parameters (while you might possibly consider hyperpriors on their parameters in turn, let's start very simple).

It looks like this model might be estimates via MCMC.

For example, your model might have something like (we might need to tweak this as I come to understand your problem better):

Your specified model for $X_t$ - this is like a random walk + loss-process + restocking process

Restocking process - $\beta_t$ is either $0$ (no restock) with probability $(1-\pi_t)$ or from some positive discrete distribution with large mean with probability $\pi_t$. It's not 100% clear whether this variable has a strict upper limit. We still have to pin down some guess at a distribution for the positive part.

$\pi_t$ goes up as $X_t$ goes down, but may be 0 above some threshold (further clarification here would help). $\pi_t$ is presumably from something like a beta distribution.

I assume we take $\alpha_t\sim \text{truncated Poisson}(\lambda)$, but do we truncate it at $0$, or some higher value (like say 1?). We might take $\lambda$ to have say a Gamma prior.

Are the observations at random times or fixed times? Are the restockings and decreases at random times between observations? Might two restocking events happen between consecutive observations, for example?

Might there be any other source of variation in $X$?

• Thans Glen_b. Rules would get me to some point. This example was too simplistic. Your last line was exactly the scenario. There is no measurement noise, but the decay is not fixed as in a physical process (like water leaking from a can), but it is probabilistic with a rate $\lambda$ – user1669710 Dec 12 '14 at 17:08
• Added more details @Glen_b – user1669710 Dec 12 '14 at 17:43
• Thanks @Glen_b. I have enough to think about. The answers to your questions are as follows. Observations are at fixed-intervals/times. Restockings & decreaseas happen at random times between observations; Two restockings can happen between consecutive observations. – user1669710 Dec 15 '14 at 20:37