> On Oct 12, 2019, at 1:52 PM, 'Mike Day' via Programming > <programm...@jsoftware.com> wrote: > > Sorry, I wasn’t considering trigrams in my off the cuff stuff, > > Mike >
Thanks Mike (Day?). Can’t always tell with fourm replies until I reply… I appreciate (and am still studying) your stuff, and learning a lot from all these exchanges. I converted your reply to a script also, and so far have {with my comments enclosed like this}: NB.> eg for Ric Sherlock’s example, modified for unequal sample sizes: NB.> Apologies for non-alignment, as seen on iPad anyway. NB. {Defs moved to front, earlier results commented, and expected to NB. change -- due to ?, but kept to sompare shape and type.} NB. {Still trying to understand the monad/duad stuff...} NB. {Changed a couple of Nb.'s t0 NB.} NB. absolute frequencies for one set fr1 =: 3 : 0 y fr1~ /:~ ~. y : alf =. x ser =. y <:@#/.~ alf, ser ) NB. relative frequencies for one set rfr1 =: (%+/)@:fr1 NB. compare frequencies cfr =: 3 : 0 y cfr~ /:~ ~.;y : alf =. x sers=. y alf&fr1 every y ) NB. compare relative frequencies crfr =: 3 : 0 y crfr~ /:~ ~.;y NB. Default base is sorted nub of all inputs. : alf =. x sers=. y alf&rfr1 every y ) ]'X Y'=: 'actg' {~ 2 30 ?@$ 4 tttgcctataaacaatgcagaccagcacgt ggcttcaacgactccagagtcttgctgagt NB.catctaagtcgataatccacttacttccgg NB.cagcaaggacaggtgctaatacacactcgc [X =: 'actg' {~ 40?@$ 4 attaggtgccgacagaagtggccaacctcatcgacaaagg NB.ttagcacttccctcagagttacccacactagctggtgcag [each NB. in Z? [&.> fr1 each X;Y NB. Absolute frequencies, using sorted nubs as base +----------+-------+ |13 10 11 6|6 8 8 8| +----------+-------+ NB.+---------+--------+ NB.|9 13 8 10|10 9 7 4| NB.+---------+--------+ rfr1 each X;Y NB. Relative freqs +---------------------+------------------------------+ |0.325 0.25 0.275 0.15|0.2 0.266667 0.266667 0.266667| +---------------------+------------------------------+ NB.+--------------------+------------------------------+ NB.|0.225 0.325 0.2 0.25|0.333333 0.3 0.233333 0.133333| NB.+--------------------+------------------------------+ NB. Comparisons crfr X;Y NB. Absolute 0.325 0.25 0.275 0.15 0.2 0.266667 0.266667 0.266667 NB.9 13 8 10 NB.10 9 7 4 NB. load'~/user/temp.ijs' crfr X;Y NB. Relative 0.325 0.25 0.275 0.15 0.2 0.266667 0.266667 0.266667 NB. 0.225 0.325 0.2 0.25 NB.0.333333 0.3 0.233333 0.133333 NB.You can supply your “alphabet” as Left argument.. 'tagc' fr1 X NB. In your preferred order! 6 13 11 10 NB.10 9 8 13 NB.fns below sign off,{now moved to front} NB.Mike NB. ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm