From c2dea6710b0d6b81abdae650fffe2b5983739ce9 Mon Sep 17 00:00:00 2001 From: Orion Yeung <11580988+orionyeung001@users.noreply.github.com> Date: Mon, 2 Dec 2024 21:53:37 -0600 Subject: [PATCH] fix: sampling should use DistIter, but not collect it --- examples/random_clap.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/random_clap.rs b/examples/random_clap.rs index 7d08d5ff..9ebc9deb 100644 --- a/examples/random_clap.rs +++ b/examples/random_clap.rs @@ -159,10 +159,10 @@ fn run_command_sample(count: Option, dist: DistributionAsCommand) -> Resu match dist { // multinomial should print `count` of Vec DistributionAsCommand::Multinomial { n, p } => { - let samples = thread_rng().sample_iter(Multinomial::new(p, n)?); + let sample_iter = thread_rng().sample_iter(Multinomial::new(p, n)?); print_multivariate_samples( count, - samples.map(|v: na::DVector| { + sample_iter.map(|v: na::DVector| { let vec: Vec<_> = v.into_iter().cloned().collect(); vec }), @@ -170,13 +170,13 @@ fn run_command_sample(count: Option, dist: DistributionAsCommand) -> Resu } // binomial should print `count` of uint DistributionAsCommand::Binomial { n, p } => { - let samples: Vec = thread_rng().sample_iter(Binomial::new(p, n)?).collect(); - print_samples(count, samples)?; + let sample_iter = thread_rng().sample_iter::(Binomial::new(p, n)?); + print_samples(count, sample_iter)?; } // normal should print `count` of float DistributionAsCommand::Normal { mu, sigma } => { - let samples = thread_rng().sample_iter(Normal::new(mu, sigma)?); - print_samples(count, samples)? + let sample_iter = thread_rng().sample_iter(Normal::new(mu, sigma)?); + print_samples(count, sample_iter)? } }