mirror of
https://github.com/maciej-bendkowski/generic-boltzmann-brain.git
synced 2024-09-11 12:48:09 +03:00
Test synonym sampler outcome distribution
This commit is contained in:
parent
50cd6352d6
commit
43b53e6990
@ -51,16 +51,28 @@ tests =
|
||||
(obsSize, obsAbs) <- runLambdaSampler 1_000
|
||||
close obsSize 10_000 0.2 -- just to be sure
|
||||
close obsAbs 4_000 0.2 -- just to be sure
|
||||
, testCase "Binary lambda sampler has the correct output distribution" $ do
|
||||
(obsSize, obsAbs) <- runBinLambdaSampler 1_000
|
||||
close obsSize 6_000 0.2 -- just to be sure
|
||||
close obsAbs 2_340 0.2 -- just to be sure
|
||||
]
|
||||
|
||||
lambdaSampler :: BuffonMachine SMGen Lambda
|
||||
lambdaSampler = rejectionSampler (MkLowerBound 8_000) (MkUpperBound 12_000)
|
||||
|
||||
binLambdaSampler :: BuffonMachine SMGen Lambda
|
||||
binLambdaSampler = rejectionSampler (MkLowerBound 5_000) (MkUpperBound 6_400)
|
||||
|
||||
runLambdaSampler :: Int -> IO (Double, Double)
|
||||
runLambdaSampler n = evalIO $ do
|
||||
sam <- replicateM n lambdaSampler
|
||||
pure $ statistics $ (\t -> (size t, abstractions t)) <$> sam
|
||||
|
||||
runBinLambdaSampler :: Int -> IO (Double, Double)
|
||||
runBinLambdaSampler n = evalIO $ do
|
||||
sam <- replicateM n binLambdaSampler
|
||||
pure $ statistics $ (\t -> (size t, abstractions t)) <$> sam
|
||||
|
||||
statistics :: [(Int, Int)] -> (Double, Double)
|
||||
statistics xs = (average $ fst <$> xs, average $ snd <$> xs)
|
||||
|
||||
|
@ -85,7 +85,7 @@ mkBoltzmannSampler
|
||||
System
|
||||
{ targetType = ''BinLambda
|
||||
, meanSize = 6_000
|
||||
, frequencies = def
|
||||
, frequencies = ('Abs, 2340) <:> def
|
||||
, weights =
|
||||
('Index, 0)
|
||||
<:> ('App, 2)
|
||||
|
Loading…
Reference in New Issue
Block a user