Speed up lea.max_of and lea.min_of functions

Issue #46 closed
Pierre Denis repo owner created an issue

The current implementation of lea.max_of and lea.min_of could be slightly optimized, without using fast=True (hence without loosing referential consistency).

Currently in lea 3.0.1, the call

lea.max_of(a,b,c)

builds something similar to

Flea.build(max,(a,b,c))

To calculate the resulting probability distribution, this has to call max(va,vb,vc) for each combination of values (va,vb,vc).

Now, if we build instead

Flea2(max,Flea2(max,a,b),c)

then the calculation could be faster because max(va,vb) shall be calculated only once for each (va,vb) pair. Note that Flea2 has the same semantic as Flea, i.e. functional random variable, but is optimized for functions having two arguments.

Of course, the same optimization could be done also on lea.min_of.

Comments (10)

  1. Log in to comment