Skip to content

Commit

Permalink
additional tests for coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
philihp committed Apr 23, 2020
1 parent 19c486e commit e7b6c85
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 17 deletions.
19 changes: 8 additions & 11 deletions src/models/thurstonMostellerFull.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,18 @@ export default (game, _options) => {
const sigSqToCiq = iSigmaSq / ciq
const gamma = Math.sqrt(iSigmaSq) / ciq

if (qRank > iRank) {
/* istanbul ignore next */
if (qRank === iRank) {
return [
omega + sigSqToCiq * v(tmp, EPSILON / ciq),
delta + ((gamma * sigSqToCiq) / ciq) * w(tmp, EPSILON / ciq),
]
}
if (qRank < iRank) {
return [
omega + -sigSqToCiq * v(-tmp, EPSILON / ciq),
delta + ((gamma * sigSqToCiq) / ciq) * w(-tmp, EPSILON / ciq),
omega + sigSqToCiq * vt(tmp, EPSILON / ciq),
delta + ((gamma * sigSqToCiq) / ciq) * wt(tmp, EPSILON / ciq),
]
}

const sign = qRank > iRank ? 1 : -1
return [
omega + sigSqToCiq * vt(tmp, EPSILON / ciq),
delta + ((gamma * sigSqToCiq) / ciq) * wt(tmp, EPSILON / ciq),
omega + sign * sigSqToCiq * v(sign * tmp, EPSILON / ciq),
delta + ((gamma * sigSqToCiq) / ciq) * w(sign * tmp, EPSILON / ciq),
]
},
[0, 0]
Expand Down
4 changes: 4 additions & 0 deletions test/statistics/v.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ test('v(0,2)', (t) => {
test('v(0,-1)', (t) => {
t.is(v(0, -1), 0.2875999734906994)
})

test('denominator less than threshold', (t) => {
t.is(v(0, 10), 10)
})
16 changes: 10 additions & 6 deletions test/statistics/vt.test.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import test from 'ava'
import { vt } from '../../src/statistics'

test('vt(1,2)', (t) => {
t.is(vt(1, 2), -0.2827861132540126)
test('with small b, small x', (t) => {
t.is(vt(-1000, -100), 1100)
})

test('vt(0,2)', (t) => {
t.is(vt(0, 2), 0)
test('with small b, big x', (t) => {
t.is(vt(1000, -100), -1100)
})

test('vt(0,-1)', (t) => {
t.is(vt(0, -1), -1)
test('with big b, small x', (t) => {
t.is(vt(-1000, 1000), 0.7978845368663289)
})

test('with big b, big x', (t) => {
t.truthy(vt(0, 1000) < 0.000000001)
})
4 changes: 4 additions & 0 deletions test/statistics/w.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ test('w(0,2)', (t) => {
test('w(0,-1)', (t) => {
t.is(w(0, -1), 0.3703137182425503)
})

test('denominator less than threshold', (t) => {
t.is(w(0, 10), 0)
})
8 changes: 8 additions & 0 deletions test/statistics/wt.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,11 @@ test('wt(0,2)', (t) => {
test('wt(0,-1)', (t) => {
t.is(wt(0, -1), 1)
})

test('wt(0,0)', (t) => {
t.is(wt(0, 0), 1.0)
})

test('wt(0,10)', (t) => {
t.truthy(wt(0, 10) < 0.000000000001)
})

0 comments on commit e7b6c85

Please sign in to comment.