# Modelling snowfall as a random walk with a drift

I am trying to simulate a (very) simple model of snow fall/accumulation using random walks in the following way:

sf =
Accumulate[RandomVariate[BernoulliDistribution[0.2], 100] *
RandomVariate[GammaDistribution[1, 2], 100] /. {0. -> -0.4}]

ListLinePlot[sf]


I generate Bernoulli trials with a success of probability of 0.2 to simulate days that it snows. On a day that it doesn't snow instead of a simple 0 entry I am introducing a negative drift term of -0.4 to emulate the melting of the snow.

Where I am having trouble is that you can't ever have negative snowfall. I want the walker to always remain bigger than or equal to 0. However, I can't just send all negative entries to 0 as that would eliminate the data of days where it snows but the drift term is larger than the snowfall.

Thanks.

## 1 Answer

I don't think Accumulate is powerful enough. Rather, you should use FoldList.

SeedRandom[2];
sf =
FoldList[If[#2 == 0, Max[#1 - .4, 0], #1 + #2] &,
RandomVariate[BernoulliDistribution[0.2], 100] *
RandomVariate[GammaDistribution[1, 2], 100]];
ListLinePlot[sf]