Maxima functions should have clear, simple, and universal semantics. Though
I do understand why column-wise min can be useful when matrices are used to
represent datasets, I find it poor practice to overload that functionality
on a function generically called 'mini'. Why not col_min and row_min?
As for the expectations of users working in a statistical context, I'll
point out that in R, min(matrix(1:4,2,2)) = min(data.frame(a=1:2,b=3:4)) =
1, NOT a column-wise minimum*, which requires the use of the 'apply'
function, which has an argument specifying the dimension along which to
group.
-s
* I admit I find this strange in the case of data frames, but then there are
many things I find strange in R.
On Mon, Jun 28, 2010 at 13:51, Barton Willis <willisb at unk.edu> wrote:
> -----maxima-bounces at math.utexas.edu wrote: -----
>
> >Perhaps, a user not working in an statistical context would expect lmax
> >to return the maximum element of the matrix, not a list of column wise
> >maxima, which is what we are looking for.
> >
> >--
> >Mario
>
> I'd guess that users would sometimes assume that lmax on a matrix gives
> the largest matrix entry. I suppose lmax and lmin could have optional
> arguments that control all this, but I think it's more useful to unify
> lmax with maxi. Plus, for matrices, we have the one and infinity norms
> already.
>
> Maybe something like (now that transpose is less spendy)
>
> (defmacro opapply (op l)
> `(simplify (cons (list ,op) ,l)))
>
> (defun $lmax (x)
> (cond ((or ($listp x) ($setp x)) (opapply '$max (margs x)))
> (($matrixp x)
> (opapply 'mlist (mapar #'(lambda (s) (opapply '$max s)) (transpose
> (mcx (margs x))))))
> (t (merror "The argument to 'lmax' must be a list, set, or
> matrix."))))
>
> (defun $lmin (x)
> (cond ((or ($listp x) ($setp x)) (opapply '$min (margs x)))
> (($matrixp x)
> (opapply 'mlist (mapar #'(lambda (s) (opapply '$min s)) (transpose
> (mcx (margs x))))))
> (t (merror "The argument to 'lmin' must be a list, set, or matrix."))))
>
>
> --Barton