# Pure function to determine next and last ping?

**URL:** <https://forum.beeminder.com/t/pure-function-to-determine-next-and-last-ping/7047>\
**Category:** TagTime\
**Created:** [July 25, 2020, 11:36am UTC](https://forum.beeminder.com/t/pure-function-to-determine-next-and-last-ping/7047 "2020-07-25T11:36:21Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![narthur](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.beeminder.com/narthur/32/5113_2.png) [@narthur](https://forum.beeminder.com/u/narthur)\
**Post date:** [July 26, 2020, 3:21pm UTC](https://forum.beeminder.com/t/pure-function-to-determine-next-and-last-ping/7047/4 "2020-07-26T15:21:16Z")

</div>

A while back I made a TagTime-like system in Android Automate. Here’s some pseudo-code that represents the scheduling strategy I used:

```auto
begin
start = 6
end = 19
length = end-start
rand = random()
run = rand <= 0.1 && hour >= start && hour < end
if run:
  ping user
wait 5 minutes
goto begin

```

There are probably good arguments for why this approach is naive, though I couldn’t articulate them, and the strategy worked well enough for what I was doing. I did have [a big discussion](https://forum.beeminder.com/t/questions-about-stochastic-time-tracking/6559) with some other users here on the forum regarding the nuances of stochastic time tracking and the practical issues I ran into trying to use it.

Also, if you’re interested in looking at my Automate flow, I’m happy to share more information / an export of the flow.

---

_[View the full topic](https://forum.beeminder.com/t/pure-function-to-determine-next-and-last-ping/7047)._
