Toggle menu
15
236
69
27.5K
Kenshi Wiki
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.
Revision as of 16:41, 8 March 2025 by Prd (talk | contribs) (Created page with "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=...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Refer to
Module:Timing



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')