Home
Random
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Timing/testcases
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
require 'Module:BDD'() local p = require('Module:Timing') describe({en='statistical analysis', nb='statistisk analyse'}, function() context({en='for a constant serie', nb='for en konstant serie'}, function() it({en='should give mean', nb='skal finnes middelverdi'}, function() expect('"p.stats"', p.stats({ -1, -1, -1 })[1]):toBe( -1 ) expect('"p.stats"', p.stats({ 0, 0 })[1]):toBe( 0 ) expect('"p.stats"', p.stats({ 2, 2, 2, 2 })[1]):toBe( 2 ) end) it({en='should give variance', nb='skal finnes varians'}, function() expect('"p.stats"', p.stats({ -1, -1, -1 })[2]):toBe( 0 ) expect('"p.stats"', p.stats({ 0, 0 })[2]):toBe( 0 ) expect('"p.stats"', p.stats({ 2, 2, 2, 2 })[2]):toBe( 0 ) end) end) context({en='for an alternating serie', nb='for en vekslende serie'}, function() it({en='should give mean', nb='skal finnes middelverdi'}, function() expect('"p.stats"', p.stats({ -1, -1, 1, 1 })[1]):toBe( 0 ) expect('"p.stats"', p.stats({ 2, 2, 4, 4 })[1]):toBe( 3 ) end) it({en='should give variance', nb='skal finnes varians'}, function() expect('"p.stats"', p.stats({ -1, -1, 1, 1 })[2]):toBe( 1 ) expect('"p.stats"', p.stats({ 2, 2, 4, 4 })[2]):toBe( 1 ) end) end) end) describe({en='difference against a baseline', nb='forskjell mot en grunnlinje'}, function() context({en='for equal pairs', nb='for like par'}, function() it({en='should give mean', nb='skal finnes middelverdi'}, function() expect('"p.combine"', p.combine({ -1, 0 }, { -1, 0 })[1]):toBe( 0 ) expect('"p.combine"', p.combine({ 2, 1 }, { 2, 1 })[1]):toBe( 0 ) end) it({en='should give variance', nb='skal finnes varians'}, function() expect('"p.combine"', p.combine({ -1, 0 }, { -1, 0 })[2]):toBe( 0 ) expect('"p.combine"', p.combine({ 2, 1 }, { 2, 1 })[2]):toBe( math.pow(2, 0.5) ) end) end) end) return result('Module:Timing')
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:Timing/testcases/doc
(
edit
)