Re: discard hi, low then avg
Posted in 1996
In article <Qmail.201.11807.823553980@gshp9000>,
hassler@gshp9000.gradsch.ohio-state.edu (Dick Hassler) wrote:
>
>Problem:
>There are 5 judges and each submits one score for each
>candidate. The candidate's average score is computed averaging
>3 remaining judges' scores after:
> Discarding the lowest score or the 1st blank if there is one.
> Discarding the highest score or the 2nd blank if there is one.
>Should 3 or more of the judges fail to submit a score I
>don't know whether to divide the sum of the scores received
>by 3 or divide the sum of the scores received by the number
>of scores received.
Just a guess - I haven't tested this.
Table --
CREATE TABLE scores(
participantID CHAR(30) NOT NULL,
eventID CHAR(30) NOT NULL,
judgeID CHAR(30) NOT NULL,
score SMALLINT
)
CREATE UNIQUE INDEX ix1_scores ON scores(participantID, eventID, judgeID)
Then --
-- Get values for calculations
SELECT sum(score), min(score), max(score), count(*)
INTO totScore, minScore, maxScore, countScore
WHERE participantID = ?? AND eventID = ?? AND score IS NOT NULL
-- Find out how many blanks
SELECT count(*)
INTO countNullScores
WHERE participantID = ?? AND eventID = ?? AND score IS NULL
LET validScore=TRUE
CASE
-- Not enough -- allows for more than 5 judges and 0 scores
WHEN countScore < minNumberScoresAllowed
averageScore = 0
LET validScore=FALSE
-- More than 1 blank, use all scores provided
WHEN countNullScores > 1
averageScore = totScore / countScore
-- One blank - eliminate min
WHEN countNullScores = 1
averageScore = (totScore - maxScore) / (countScore - 1)
OTHERWISE
-- No blanks - eliminate min and max
averageScore = (totScore - (minScore + maxScore) ) / (countScore - 2)
END CASE
John Callaway
Bath Iron Works
The opinions stated above are my own and should be run through sanity.check