@@ -57,27 +57,33 @@ impl CpuLogpFunc for PosteriorDensity {
57
57
}
58
58
}
59
59
60
- // We get the default sampler arguments
61
- let mut settings = DiagGradNutsSettings :: default ();
62
-
63
- // and modify as we like
64
- settings . num_tune = 1000 ;
65
- settings . maxdepth = 3 ; // small value just for testing...
66
-
67
- // We instanciate our posterior density function
68
- let logp_func = PosteriorDensity {};
69
- let math = CpuMath :: new (logp_func );
70
-
71
- let chain = 0 ;
72
- let mut rng = thread_rng ();
73
- let mut sampler = settings . new_chain (0 , math , & mut rng );
74
-
75
- // Set to some initial position and start drawing samples.
76
- sampler . set_position (& vec! [0f64 ; 10 ]). expect (" Unrecoverable error during init" );
77
- let mut trace = vec! []; // Collection of all draws
78
- for _ in 0 .. 2000 {
79
- let (draw , info ) = sampler . draw (). expect (" Unrecoverable error during sampling" );
80
- trace . push (draw );
60
+
61
+ fn main () {
62
+ // We get the default sampler arguments
63
+ let mut settings = DiagGradNutsSettings :: default ();
64
+
65
+ // and modify as we like
66
+ settings . num_tune = 1000 ;
67
+ settings . maxdepth = 3 ; // small value just for testing...
68
+
69
+ // We instanciate our posterior density function
70
+ let logp_func = PosteriorDensity {};
71
+ let math = CpuMath :: new (logp_func );
72
+
73
+ let chain = 0 ;
74
+ let mut rng = thread_rng ();
75
+ let mut sampler = settings . new_chain (0 , math , & mut rng );
76
+
77
+ // Set to some initial position and start drawing samples.
78
+ sampler
79
+ . set_position (& vec! [0f64 ; 10 ])
80
+ . expect (" Unrecoverable error during init" );
81
+ let mut trace = vec! []; // Collection of all draws
82
+ for _ in 0 .. 2000 {
83
+ let (draw , info ) = sampler . draw (). expect (" Unrecoverable error during sampling" );
84
+ trace . push (draw . clone ());
85
+ println! (" Draw: {:?}" , draw );
86
+ }
81
87
}
82
88
```
83
89
0 commit comments