Illustrating half life

I'm teaching some lessons on negative exponents and one application listed was half life since the rate of decay can be written as 2^-1 every __ years.

I found this nice animation on the net.

http://www.absorblearning.com/media/attachment.action?quick=185&att=3167

I certainly don't need anything near that fancy, but wondered how I could model a similar kind of graphic using mathematica, where I could use a slider to represent years, and show a grid that responded by randomly choosing dots to "turn" off as time moved along.

Any starting hints or answers are welcomed.

Tom

-

I would recommend to check out Demonstrations site. The apps there are free and source code is available. Many neat apps come up for a general search:

This one seems what you need - it is better than that animation actually ;)

For your class you can also use other ready-to-use things right of Mathematica. I am not sure if you are aware of this, but due to Wolfram|Alpha integration, Mathematica can do some neat pre-built outputs. In your case, for example,

Row[{WolframAlpha["radon 222", {{"DecayChain:IsotopeData", 1}, "Content"}],


-
Thanks! I had actually seen that, it's excellent. I did wonder though, to create something that was more time "sensitive". In that demonstration, the time slider goes in increments of 1, so things only happen at t = 1, t = 2 , and so on. In theory anyway, suppose you used a half life of 5700 years (Carbon - 14). And suppose the time slider went all the way from 0 to 20000 years. In theory, the whole time you move the slider, there will be some decay happening. Not at all sure how to begin to implement that. It would also illustrate ideas from experimental/theoretical prob. –  Tom De Vries Mar 27 '13 at 19:44
@TomDeVries The source code for the demonstration is very short. You can easily see through it and modify it to your own version. –  Vitaliy Kaurov Mar 27 '13 at 20:37

Here is a toy demonstration. I'm not sure it actually models half life, but it's half-life-ish. "λish," if you will. Anyway the point is to show one approach toward making a "naturalistic" demonstration.

toy[n_, interval_: .3] := Module[{init, units, grid, proc, count = 0},
init[] := (
units = ConstantArray[Gray, n^2];
count = 0);

grid = Dynamic[Grid[Partition[
Graphics[{#, Disk[]}, ImageSize -> 20] & /@ units,
n]]];

proc[] := While[True,
Pause[interval]; count++;
units[[RandomInteger[{1, n^2}]]] = White;
If[Count[units, Gray] <= n^2/2,
count = Style[count, Underlined];
Break[]]];

init[];

{grid, Dynamic[count], Button[go, init[]; proc[], Method -> "Queued"]}];


A version with history:

toy[n_, interval_: .3] :=
Module[{init, units, grid, proc, history, count},
init[] := (
history = {n^2};
units = ConstantArray[Gray, n^2];
count = 0);

grid = Dynamic[Grid[Partition[
Graphics[{#, Disk[]}, ImageSize -> 20] & /@ units,
n]]];

proc[] := While[True,
Pause[interval];
AppendTo[history, Count[units, Gray]];
count++;
units[[RandomInteger[{1, n^2}]]] = White;
If[Count[units, Gray] <= n^2/2,
count = Style[count, Underlined];
Break[]];
];

init[];

{grid, Dynamic[count], Dynamic[ListLinePlot[history]],
Button[go, init[]; proc[], Method -> "Queued"]}];


It could use some performance improvements. I community wikified this answer in case anyone has ideas.

-