Hey Jack,
On 2026-05-25 22:32, Jack Kamm wrote:
> Not sure this is the "right" loss function (or if there is one). It
> assumes the goal is to minimize the residual to a particular linear
> function.
Well certainly you could choose other things, but IMO average absolute
error isn’t an unreasonable thing to minimize, and is what some people
think of when trying to be ‘close’ to the original fraction.
> But one might prefer another objective, for example to divide the
> Org priorities as evenly as possible into the 9 groups. For example
> if there are 90 Org priority levels, it feels natural to have the
> Org -> iCal map
>
> [1,10] -> 1, [11,20] -> 2, ..., [81,90] -> 9
>
> so that each iCal priority would contain 10 Org priorities.
Sure, that’s a valid preference that isn’t inconsistent with rounding
(see below).
> An alternative that would achieve a more even distribution is
>
> (floor (+ 1 (* 8. (/ (float (- pri org-priority-lowest))
> (+ 1 (- org-priority-highest
> org-priority-lowest))))))
> --8<--
> this function uses N in the denominator instead of (N-1), so that
> the range is [0,1) instead of [0,1], so that all the steps can be
> half-open (preventing the boundary issue).
I think you mean:
floor(1 + 8(p-H)/(L-H+1)) : {H,…,L} -> {1,…,8}?
This completely cuts out priority 9, so it introduces a boundary issue
at p = L, but is otherwise very close to (N-1):
# # # # # # # #
# # # # # # # #
# # # # # # # #
---|---|---|---|---|---|---|---|---|---
1 2 3 4 5 6 7 8 9
The real issue seems to be all our formula are mapping onto [1,9)
which has length 8, instead of something like [1,10):
floor(1 + 9(p-H)/(L-H+1)) : {H,…,L} -> {1,…,9}
# # # # # # # # #
# # # # # # # # #
# # # # # # # # #
---|---|---|---|---|---|---|---|---|---
1 2 3 4 5 6 7 8 9
or, a more symmetric version with rounding by mapping onto the
interval [0.5,9.5] (you just have to be careful at the half-integers
because of the tie-to-even behaviour):
round(1/2 + 9(p-H)/(L-H)) : {H,…,L} -> {1,…,9}
# # # # # # # # #
# # # # # # # # #
# # # # # # # # #
---|---|---|---|---|---|---|---|---|---
1 2 3 4 5 6 7 8 9
> this function may not be desired when the number of Org priorities
> is low -- for example, in the case of Org priorities A-C, it maps
>
> A -> 1, B-> 3, C -> 6
>
> instead of
>i
> A -> 1, B -> 5, C -> 9
>
> which is the behavior of the current exporter as well as your
> proposal.
The current approach is getting lucky: rounding is usually symmetric
around 5, but the floor is generally not, e.g. with N = 4:
|---+----------------+-------+-------+------------+-------+------------+-------|
| p | 1+8(p-1)/(N-1) | floor | round | 1+8(p-1)/N | floor | 1+9(p-1)/N | floor |
|---+----------------+-------+-------+------------+-------+------------+-------|
| 1 | 1.00000 | 1 | 1 | 1.00000 | 1 | 1.00000 | 1 |
| 2 | 3.66667 | 3 | 4 | 3.00000 | 3 | 3.00000 | 3 |
| 3 | 6.33333 | 6 | 6 | 5.00000 | 5 | 5.00000 | 5 |
| 4 | 9.00000 | 9 | 9 | 7.00000 | 7 | 7.00000 | 7 |
|---+----------------+-------+-------+------------+-------+------------+-------|
#+TBLFM:
$1=@#-1::$2=1+8($1-@2$1)/(@>$1-@2$1);%.5f::$3=floor($2);%d::$4=round($2);%d::$5=1+8($1-@2$1)/(@>$1-@2$1+1);%.5f::$6=floor($5);%d::$7=1+8($1-@2$1)/(@>$1-@2$1+1);%.5f::$8=floor($7);%d
> A possible way to address this under the partitioning [0,1) approach
> would be to relabel the non-empty segments so that they match some
> desired behavior, e.g. the current behavior of making them as far
> apart as possible on {1,...9}, or possibly some other behavior (e.g.
> some users might prefer to map A->1, B->2, C->3).
I think that should be covered by the user option: we provide some
‘standard’ choices, or a user can directly map {H,…,L} -> {1,…9} with
their own function. What do you think the options should be?
Thanks,
--
Jacob S. Gordon
[email protected]
Please don’t send me HTML emails or MS Office/Apple iWork documents.
https://useplaintext.email/#etiquette
https://www.fsf.org/campaigns/opendocument