Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- type JS = Integer
- type GS = Integer
- type Rank = Integer
- newtype Median = Median (G, G)
- median :: G -> G -> Median
- rankOfMajorityValue :: GS -> MajorityValue (Ranked grade) -> Rank
- majorityValueOfRank :: JS -> GS -> Rank -> MajorityValue (Ranked ())
- positionOfMajorityValue :: GS -> MajorityValue (Ranked grade) -> Rational
- countMerits :: JS -> GS -> Integer
- lastRank :: JS -> GS -> Rank
- countMedian :: JS -> GS -> Median -> Integer
- countMediansBefore :: JS -> GS -> G -> Median -> Integer
- listMediansBefore :: JS -> GS -> G -> Median -> [Median]
- probaMedian :: JS -> GS -> [Rational]
- nCk :: Integral i => i -> i -> i
Convenient type aliases
Rank of a MajorityValue
.
Type Median
Ranking and unranking MajorityValue
s
rankOfMajorityValue :: GS -> MajorityValue (Ranked grade) -> Rank Source #
(
returns
the number of possible rankOfMajorityValue
gs mv)MajorityValue
s lower than given mv
.
rankOfMajorityValue
gs .majorityValueOfRank
js gs<$>
[0..lastRank
js gs] == [0..lastRank
js gs]
majorityValueOfRank :: JS -> GS -> Rank -> MajorityValue (Ranked ()) Source #
The inverse of rankOfMajorityValue
.
majorityValueOfRank
js gs .rankOfMajorityValue
gs ==id
positionOfMajorityValue :: GS -> MajorityValue (Ranked grade) -> Rational Source #
Counting Merit
s
countMerits :: JS -> GS -> Integer Source #
(
returns the number of possible countMerits
js gs)Merit
s of size js
using grades gs
.
That is the number of ways to divide a segment of length js
into at most gs
segments whose size is between '0' and js
.
The formula is: (js+gs-1)·(js+gs-2)·…·(js+1)·js / (gs-1)·(gs-2)·…·2·1
which is: (js+gs-1)
nCk
(gs-1)
lastRank :: JS -> GS -> Rank Source #
(
returns the rank of the lastRank
js gs)MajorityValue
composed of js
times the highest grade of gs
.
.lastRank
js gs == countMerits
js gs - 1
Counting Median
s
countMedian :: JS -> GS -> Median -> Integer Source #
(
returns the number of possible countMedian
js gs (Median
(l,h)))Merit
s of length js
using grades gs
,
which have (l,h)
as lower and upper median grades.
This is done by multiplying together
the countMerits
to the left of l
and the countMerits
to the right of h
.
countMediansBefore :: JS -> GS -> G -> Median -> Integer Source #
(
returns the number of possible countMediansBefore
js gs previousHigh (Median
(low,high)))Merit
s with js
judges and gs
grades,
whose
is such that Median
(l,h)((l,h) < (low, high))
and (previousHigh <= h)
.
listMediansBefore :: JS -> GS -> G -> Median -> [Median] Source #
(
returns the listMediansBefore
js gs previousHigh (Median
(low,high)))Median
s of possible Merit
s with js
judges and gs
grades
with a Median
strictly lower than (low,high)
.
probaMedian :: JS -> GS -> [Rational] Source #
(
compute the probability
of each grade to be a probaMedian
js gs)MajorityGrade
given js
judges and gs
grades.