@@ -18,10 +18,9 @@ settings.
18
18
19
19
import numpy as np
20
20
import scipy.stats
21
- import matplotlib
22
21
import matplotlib.pyplot as plt
23
22
import logging
24
- logging.basicConfig(level=logging.INFO)
23
+ logging.basicConfig(level=logging.INFO) # sometimes this is required to enable logging inside Jupyter
25
24
26
25
%matplotlib inline
27
26
%precision 2
@@ -251,7 +250,7 @@ a DAG.
251
250
252
251
253
252
254
- .. note :: You will need the Graphviz_ software as well as the graphviz `Python package`_ (https://pypi.python.org/pypi/graphviz) for drawing this. The software is already installed in many unix-like OS.
253
+ .. note :: You will need the Graphviz_ software as well as the graphviz `Python package`_ (https://pypi.python.org/pypi/graphviz) for drawing this.
255
254
256
255
.. _Graphviz : http://www.graphviz.org
257
256
.. _`Python package` : https://pypi.python.org/pypi/graphviz
@@ -396,8 +395,8 @@ time is spent in drawing.
396
395
397
396
.. parsed-literal ::
398
397
399
- CPU times: user 2.28 s, sys: 165 ms, total: 2.45 s
400
- Wall time: 2.45 s
398
+ CPU times: user 1.6 s, sys: 166 ms, total: 1.77 s
399
+ Wall time: 1.76 s
401
400
402
401
403
402
The ``sample `` method returns a ``Sample `` object, which contains
@@ -452,8 +451,8 @@ as long as it takes to generate the requested number of samples.
452
451
453
452
.. parsed-literal ::
454
453
455
- CPU times: user 222 ms, sys: 40.3 ms, total: 263 ms
456
- Wall time: 261 ms
454
+ CPU times: user 198 ms, sys: 35.5 ms, total: 233 ms
455
+ Wall time: 231 ms
457
456
Method: Rejection
458
457
Number of samples: 1000
459
458
Number of simulations: 40000
@@ -497,9 +496,9 @@ been reached or a maximum of one second of time has been used.
497
496
498
497
Method: Rejection
499
498
Number of samples: 1000
500
- Number of simulations: 190000
501
- Threshold: 0.0855
502
- Sample means: t1: 0.561, t2: 0.218
499
+ Number of simulations: 180000
500
+ Threshold: 0.088
501
+ Sample means: t1: 0.561, t2: 0.221
503
502
504
503
505
504
@@ -547,8 +546,8 @@ in our model:
547
546
548
547
.. parsed-literal ::
549
548
550
- CPU times: user 5.26 s, sys: 37.1 ms, total: 5.3 s
551
- Wall time: 5.3 s
549
+ CPU times: user 5.01 s, sys: 60.9 ms, total: 5.07 s
550
+ Wall time: 5.09 s
552
551
553
552
554
553
@@ -558,8 +557,8 @@ in our model:
558
557
Method: Rejection
559
558
Number of samples: 1000
560
559
Number of simulations: 1000000
561
- Threshold: 0.036
562
- Sample means: t1: 0.561 , t2: 0.227
560
+ Threshold: 0.0363
561
+ Sample means: t1: 0.554 , t2: 0.216
563
562
564
563
565
564
@@ -580,8 +579,8 @@ anything. Let's do that.
580
579
581
580
.. parsed-literal ::
582
581
583
- CPU times: user 636 ms, sys: 1 .35 ms, total: 638 ms
584
- Wall time: 638 ms
582
+ CPU times: user 423 ms, sys: 3 .35 ms, total: 426 ms
583
+ Wall time: 429 ms
585
584
586
585
587
586
@@ -591,8 +590,8 @@ anything. Let's do that.
591
590
Method: Rejection
592
591
Number of samples: 1000
593
592
Number of simulations: 1000000
594
- Threshold: 0.0452
595
- Sample means: t1: 0.56 , t2: 0.228
593
+ Threshold: 0.0457
594
+ Sample means: t1: 0.55 , t2: 0.216
596
595
597
596
598
597
@@ -610,8 +609,8 @@ simulations and only have to simulate the new ones:
610
609
611
610
.. parsed-literal ::
612
611
613
- CPU times: user 1.72 s, sys: 10.6 ms, total: 1.73 s
614
- Wall time: 1.73 s
612
+ CPU times: user 1.44 s, sys: 17.9 ms, total: 1.46 s
613
+ Wall time: 1.47 s
615
614
616
615
617
616
@@ -621,8 +620,8 @@ simulations and only have to simulate the new ones:
621
620
Method: Rejection
622
621
Number of samples: 1000
623
622
Number of simulations: 1200000
624
- Threshold: 0.0417
625
- Sample means: t1: 0.561 , t2: 0.225
623
+ Threshold: 0.0415
624
+ Sample means: t1: 0.55 , t2: 0.215
626
625
627
626
628
627
@@ -640,8 +639,8 @@ standard numpy .npy files:
640
639
641
640
.. parsed-literal ::
642
641
643
- CPU times: user 25.8 ms, sys: 3.27 ms, total: 29 ms
644
- Wall time: 28.5 ms
642
+ CPU times: user 28.7 ms, sys: 4.5 ms, total: 33.2 ms
643
+ Wall time: 33.4 ms
645
644
646
645
647
646
This stores the simulated data in binary ``npy `` format under
@@ -658,7 +657,7 @@ This stores the simulated data in binary ``npy`` format under
658
657
659
658
.. parsed-literal ::
660
659
661
- Files in pools/arraypool_3521077242 are ['d.npy', 't1.npy', 't2.npy', 'Y.npy']
660
+ Files in pools/arraypool_3375867934 are ['d.npy', 't1.npy', 't2.npy', 'Y.npy']
662
661
663
662
664
663
Now lets load all the parameters ``t1 `` that were generated with numpy:
@@ -672,7 +671,7 @@ Now lets load all the parameters ``t1`` that were generated with numpy:
672
671
673
672
.. parsed-literal ::
674
673
675
- array([ 0.79, -0.01 , -1.47 , ..., 0.98 , 0.18 , 0.5 ])
674
+ array([ 0.36, 0.47 , -1.66 , ..., 0.09 , 0.45 , 0.2 ])
676
675
677
676
678
677
@@ -687,7 +686,7 @@ We can also close (or save) the whole pool if we wish to continue later:
687
686
688
687
.. parsed-literal ::
689
688
690
- arraypool_3521077242
689
+ arraypool_3375867934
691
690
692
691
693
692
And open it up later to continue where we were left. We can open it
@@ -718,12 +717,12 @@ You can delete the files with:
718
717
os.listdir(arraypool.path)
719
718
720
719
except FileNotFoundError:
721
- print("The directry is removed")
720
+ print("The directory is removed")
722
721
723
722
724
723
.. parsed-literal ::
725
724
726
- The directry is removed
725
+ The directory is removed
727
726
728
727
729
728
Visualizing the results
@@ -820,8 +819,9 @@ sampler:
820
819
smc = elfi.SMC(d, batch_size=10000, seed=seed)
821
820
822
821
For sampling, one has to define the number of output samples, the number
823
- of populations and a *schedule * i.e. a list of quantiles to use for each
824
- population. In essence, a population is just refined rejection sampling.
822
+ of populations and a *schedule * i.e. a list of thresholds to use for
823
+ each population. In essence, a population is just refined rejection
824
+ sampling.
825
825
826
826
.. code :: ipython3
827
827
@@ -839,8 +839,8 @@ population. In essence, a population is just refined rejection sampling.
839
839
840
840
.. parsed-literal ::
841
841
842
- CPU times: user 1.72 s, sys: 154 ms, total: 1.87 s
843
- Wall time: 1.56 s
842
+ CPU times: user 1.6 s, sys: 156 ms, total: 1.75 s
843
+ Wall time: 1.38 s
844
844
845
845
846
846
We can have summaries and plots of the results just like above:
0 commit comments