# ratiominding

**URL:** <https://forum.beeminder.com/t/ratiominding/1499>\
**Category:** uncategorized\
**Created:** [May 9, 2014, 9:17pm UTC](https://forum.beeminder.com/t/ratiominding/1499 "2014-05-09T21:17:11Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![dreev](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.beeminder.com/dreev/32/4311_2.png) [@dreev](https://forum.beeminder.com/u/dreev)\
**Post date:** [May 9, 2014, 9:17pm UTC](https://forum.beeminder.com/t/ratiominding/1499/1 "2014-05-09T21:17:11Z")

</div>

Have you ever wanted to beemind a ratio, like being on time to more than half your meetings? Someone asked how to do that recently and I didn’t have a good answer but our own Alice Monday had a clever suggestion:

Make a Do Less goal for tardiness that has a rate of zero [1] and then every time you’re late you enter a 1, but every time you’re on time you enter a -1. (If you want to enforce less than 50% tardiness then being on time might only be a -.5, ie, you need to be on time twice to balance being late once.)

Slightly convoluted but I think it would work. Has anyone tried such a thing or have better ideas?

[1] Or 0.00001 since it won’t let you create it with a rate of exactly 0, though you can change it to exactly 0 with the road dial after it’s created.

PS: You could have the slope be, say, 1 per week which would mean you have to keep your lateness ratio below your threshold _but_ you also get one freebie lateness per week. If you have lots of appointments that wouldn’t affect the ratio much.

---

<div class="post-metadata">

**Author:** ![Alex\_Schell](https://avatars.discourse-cdn.com/v4/letter/a/34f0e0/32.png) [@Alex\_Schell](https://forum.beeminder.com/u/Alex_Schell)\
**Post date:** [July 31, 2014, 11:50pm UTC](https://forum.beeminder.com/t/ratiominding/1499/2 "2014-07-31T23:50:31Z")

</div>

I wanted to do this last year (to not be late to classes/appointments) and  
just thought about it again now.

With some help from semi-autodata (or new functionality), this should be  
doable in a way that’s visually nicer than Alice’s idea. Start with a new  
Do Less goal with the target ratio set as your daily rate. Then enter your  
data (in 0s and 1s) to a script that averages multiple datapoints per day,  
and sends the cumulative sum to Beeminder (this horribleness is necessary  
because aggday:mean and autosum aren’t compatible at the moment) Finally,  
to “neutralize” days with no data, disable PPR and have the script add a  
datapoint equal to your daily rate iff you haven’t entered any data that  
day. This setup should also mesh nicely with the max safe days option, like  
if you never want to exceed your ratio in any n-day period.

Here’s an example graph with some imported simulated data (try to ignore  
the YBR): [https://www.beeminder.com/alexschell/goals/ratio](https://www.beeminder.com/alexschell/goals/ratio)

An alternative to the script would be made possible by compatibility of  
autosum and aggday:mean (not sure how feasible this is), and by a  
customizable PPR: PPR = r - p_yaw_lnw where p is a positive ‘pessimism  
parameter’ (set p to 0 for ratiominding).

[migrated from Akratics Anonymous]

---

<div class="post-metadata">

**Author:** ![dreev](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.beeminder.com/dreev/32/4311_2.png) [@dreev](https://forum.beeminder.com/u/dreev)\
**Post date:** [August 1, 2014, 6:53pm UTC](https://forum.beeminder.com/t/ratiominding/1499/3 "2014-08-01T18:53:44Z")

</div>

Hey Alex, I’m super curious if you reinvented that PPR formula or if you got it from [http://doc.bmndr.com/ppr](http://doc.bmndr.com/ppr)

As for autosum + aggday=mean, I actually expect that to work fine. Why do you say they’re not compatible? (A long time ago they weren’t; is that what you’re remembering, or you tried recently and it’s not working?)

---

<div class="post-metadata">

**Author:** ![Alex\_Schell](https://avatars.discourse-cdn.com/v4/letter/a/34f0e0/32.png) [@Alex\_Schell](https://forum.beeminder.com/u/Alex_Schell)\
**Post date:** [August 1, 2014, 7:00pm UTC](https://forum.beeminder.com/t/ratiominding/1499/4 "2014-08-01T19:00:36Z")

</div>

Reinventing it with the same notation would be quite a feat 🙂 I remembered it from the old post you made to this list.

I tried the autosum and aggday mean combination before I posted yesterday, and got an error message telling me it couldn’t plot the graph because they’re not compatible.

---

<div class="post-metadata">

**Author:** ![dreev](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.beeminder.com/dreev/32/4311_2.png) [@dreev](https://forum.beeminder.com/u/dreev)\
**Post date:** [August 1, 2014, 7:08pm UTC](https://forum.beeminder.com/t/ratiominding/1499/5 "2014-08-01T19:08:50Z")

</div>

Doh! I think I refactored that so aggday and autosum are truly orthogonal but left in the error check. Possibly on purpose since aggday=mean with autosum is a super weird thing to want. 🙂 But I shall see if it’s as simple as removing the paternalistic error!

---

<div class="post-metadata">

**Author:** ![Alex\_Schell](https://avatars.discourse-cdn.com/v4/letter/a/34f0e0/32.png) [@Alex\_Schell](https://forum.beeminder.com/u/Alex_Schell)\
**Post date:** [August 1, 2014, 7:17pm UTC](https://forum.beeminder.com/t/ratiominding/1499/6 "2014-08-01T19:17:12Z")

</div>

That would be nice! Definitely let me know if you’re able to remove the error check.

---

<div class="post-metadata">

**Author:** ![dreev](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.beeminder.com/dreev/32/4311_2.png) [@dreev](https://forum.beeminder.com/u/dreev)\
**Post date:** [August 1, 2014, 7:20pm UTC](https://forum.beeminder.com/t/ratiominding/1499/7 "2014-08-01T19:20:26Z")

</div>

Done! Working for me as expected at [beeminder.com/d/test](http://beeminder.com/d/test) – at first I thought it was wrong but it was just including the initial zero datapoint in the mean, which is the right behavior (given that you want to do something so crazy in the first place!) 🙂

---

<div class="post-metadata">

**Author:** ![Alex\_Schell](https://avatars.discourse-cdn.com/v4/letter/a/34f0e0/32.png) [@Alex\_Schell](https://forum.beeminder.com/u/Alex_Schell)\
**Post date:** [August 1, 2014, 7:24pm UTC](https://forum.beeminder.com/t/ratiominding/1499/8 "2014-08-01T19:24:57Z")

</div>

Oh my. Very impressive support!! Thanks so much! I’ll give this a try later.

---

<div class="post-metadata">

**Author:** ![dreev](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.beeminder.com/dreev/32/4311_2.png) [@dreev](https://forum.beeminder.com/u/dreev)\
**Post date:** [August 1, 2014, 7:41pm UTC](https://forum.beeminder.com/t/ratiominding/1499/9 "2014-08-01T19:41:17Z")

</div>

🙂 No problem. It’s an easy UVI for us! Speaking of which, do you have a twitter name? If not I’ll tweet it like this:  
“Removed the needless error checks preventing craziness like aggday=mean for autosumming goals since crazy people like Alex Schell wanted it!”

---

<div class="post-metadata">

**Author:** ![Alex\_Schell](https://avatars.discourse-cdn.com/v4/letter/a/34f0e0/32.png) [@Alex\_Schell](https://forum.beeminder.com/u/Alex_Schell)\
**Post date:** [August 1, 2014, 8:31pm UTC](https://forum.beeminder.com/t/ratiominding/1499/10 "2014-08-01T20:31:45Z")

</div>

Haha, I’m not on Twitter. Go ahead and tweet it like that 🙂

---

<div class="post-metadata">

**Author:** ![Alex\_Schell](https://avatars.discourse-cdn.com/v4/letter/a/34f0e0/32.png) [@Alex\_Schell](https://forum.beeminder.com/u/Alex_Schell)\
**Post date:** [August 2, 2014, 8:25pm UTC](https://forum.beeminder.com/t/ratiominding/1499/11 "2014-08-02T20:25:58Z")

</div>

Upon trying this out, I think I found another easy UVI for you guys: aggday=mean seems to behave like aggday=uniqmean.

See e.g. [https://www.beeminder.com/alexschell/goals/otp](https://www.beeminder.com/alexschell/goals/otp). The datapoints are 0, 0, 0, 0, 1, 1, 1.1. The mean should be 0.3 but the aggregation (with aggday=mean) is 0.7, which is mean(0, 1, 1.1).

---

<div class="post-metadata">

**Author:** ![dreev](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.beeminder.com/dreev/32/4311_2.png) [@dreev](https://forum.beeminder.com/u/dreev)\
**Post date:** [August 2, 2014, 10:46pm UTC](https://forum.beeminder.com/t/ratiominding/1499/12 "2014-08-02T22:46:07Z")

</div>

ah ha, you are right, but apparently that was on purpose, though i no longer recall why (something about the elaborate weight-loss rules we had in the early days). so “mean” is indeed an alias for “uniqmean” but you can pick “truemean” to not do the de-duping.

here’s the whole story, straight from the code, on all the possible aggday settings (as you can see, it’s dirt simple to add more if you have proposals):

```
AGGR = { # Map possible aggday settings to lambdas that aggregate thusly
'last' : lambda x: x[-1],
'first' : lambda x: x[0],
'min' : lambda x: min(x),
'max' : lambda x: max(x),
'truemean' : lambda x: np.mean(x),
'uniqmean' : lambda x: np.mean(deldups(x)),
'mean' : lambda x: np.mean(deldups(x)),
'median' : lambda x: np.median(x),
'mode' : lambda x: scipy.mode(x), # mma: Median@Commonest
'trimmean' : lambda x: scipy.trim_mean(x, 0.1),
'sum' : lambda x: np.sum(x),
'jolly' : lambda x: 1 if x else 0
}
```

---

<div class="post-metadata">

**Author:** ![Alex\_Schell](https://avatars.discourse-cdn.com/v4/letter/a/34f0e0/32.png) [@Alex\_Schell](https://forum.beeminder.com/u/Alex_Schell)\
**Post date:** [August 3, 2014, 3:59am UTC](https://forum.beeminder.com/t/ratiominding/1499/13 "2014-08-03T03:59:06Z")

</div>

Thanks, I didn’t notice truemean in the list! No UVI then 😕

Anyway, I noticed that unlike Alice’s proposal, mine is not actually correct because it averages by day instead of averaging over all datapoints. For instance, day1 = [0]; day2 = [1, 1, 1] gets plotted as 0 + 1 = 1, whereas day1 = [1] and day2 = [0, 1, 1] gets plotted as 1 + 0.67 = 1.67; the actual value should be ratio \* nday = 0.75 \* 2 = 1.5. My approach is correct in expectation only if the ratio on a day is independent of the number of data points on that day.

The correct solution for visually appealing ratiominding is to plot the ratio so far (mean of all 0/1 datapoints) multiplied by the number of days since the goal started.

---

<div class="post-metadata">

**Author:** ![stevenzhang](https://avatars.discourse-cdn.com/v4/letter/s/839c29/32.png) [@stevenzhang](https://forum.beeminder.com/u/stevenzhang)\
**Post date:** [October 22, 2018, 11:13am UTC](https://forum.beeminder.com/t/ratiominding/1499/14 "2018-10-22T11:13:36Z")

</div>

… 4 years later… Has anyone come up with a workaround that doesn’t involve an external script?

For me, I’m trying to ratio mind to Toggl project times via IFTTT. If maybe there was an IFTTT “functions” service…
