diff options
| author | James Smith <js5@sanger.ac.uk> | 2022-07-06 01:26:03 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-06 01:26:03 +0100 |
| commit | 8a2be80b1dbbf239cf524ed56f7578f2fb91f732 (patch) | |
| tree | a99652f6614e566baaa1f7ef28dbd986bc986795 | |
| parent | 2f902fb082a394f511f83dc9b23d20ca44ee08ea (diff) | |
| download | perlweeklychallenge-club-8a2be80b1dbbf239cf524ed56f7578f2fb91f732.tar.gz perlweeklychallenge-club-8a2be80b1dbbf239cf524ed56f7578f2fb91f732.tar.bz2 perlweeklychallenge-club-8a2be80b1dbbf239cf524ed56f7578f2fb91f732.zip | |
Update README.md
| -rw-r--r-- | challenge-172/james-smith/README.md | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/challenge-172/james-smith/README.md b/challenge-172/james-smith/README.md index 7fe8ecdb67..7d1e63731f 100644 --- a/challenge-172/james-smith/README.md +++ b/challenge-172/james-smith/README.md @@ -69,6 +69,18 @@ We will present three code solutions as the quartiles and median are not-uniquel * `fivenum_med` - if the median/quartile falls between two entries - then the average of the two values is used * `fivenum_avg` - if the median/quartile falls between two entries - then a weighted average is used. With more weight given to the point nearest the fraction { for median this will be the mid-point } but for the quartiles the weighting could be 1/4 : 3/4. +These each take a similar form. + + * Sort the values lowest to highest - the only real way to do this; + * Then we run a series of maps. + * Firstly get the index of the points + * min is `0`; + * max is `$N-1`; + * the other three are distributed evenly between them + * We then convert them to an integer index and: + * the fractional part (`fivenum_avg`) OR + * indicator whether there is a factional part (`fivenum_mid` and `fivenum_range`) + * We then compute the value for that index ```perl sub fivenum_avg { my @sort = sort { $a <=> $b } @_; # sort values |
