dear group,
currently we (me and my students) are studying a book on elementary probability theory
(with use CAS DERIVE as assistent) and are porting some of the code to (wx)Maxima 5.12.
Some of the basic concepts we will define ab ovo, before we will switch to Mario
Riotorto's massive application package 'descriptive.mac' in order to draw histograms etc.
One early problem is to define the 'frequency of a in list v_'.
The Derive code is:
H(a, v_) := DIM(SELECT(x = a, x, v_))
I defined the helper function
(%i1) select(a,L) := block([LL:[]], for x in L do if x=a then LL:cons(x,LL),LL)$
(%i2) select(2,[3,2,4,2]);
(%i3) H(a,L):= length(select(a,L));
(%i4) H(2,[3,2,4,2,5]);
(%o4) 2
which seems ok.
Q1: is there a predefined function 'select' (with another name?) in Maxima
I have overlooked?
Q2: I would like to have a 'more functional and general' version of select.
Does a member of the Maxima community has some hints?
--
HTH Wolfgang