in reply to Help fixing this piece of code
This assumes unimodal datasets:
sub mode{ my %h; ++$h{ $_ } for @_; return ( sort{ $h{ $b } <=> $h{ $a } } keys %h )[ 0 ] };; @data = qw[2 3 3 3 5 7 8 12 32 44 55 12 3 23 43 33 1 4 25 43 42 1 4 5 +3 3 3];; print mode( @data );; 3
You'd need to so a bit more work to discover bi/multimodal datasets.
Anyone got any experience of this phone's predecessor?
|
|---|