# Difference between RANDOM, REGULAR and NONE sampling

**URL:** <https://discourse.itk.org/t/difference-between-random-regular-and-none-sampling/5365>\
**Category:** Algorithms\
**Tags:** sampling, simpleitk, registration, python\
**Created:** [September 26, 2022, 2:59pm UTC](https://discourse.itk.org/t/difference-between-random-regular-and-none-sampling/5365 "2022-09-26T14:59:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![debapriya](https://discourse.itk.org/letter_avatar_proxy/v4/letter/d/bc79bd/32.png) [@debapriya](https://discourse.itk.org/u/debapriya)\
**Post date:** [September 26, 2022, 2:59pm UTC](https://discourse.itk.org/t/difference-between-random-regular-and-none-sampling/5365/1 "2022-09-26T14:59:17Z")

</div>

I have run the same registration code snippet, with the same data and same sampling strategy, multiple times. I get different result each time. With RANDOM sampling, this is understandable, but why should REGULAR and NONE sampling show different result each time?

---

<div class="post-metadata">

**Author:** ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)\
**Post date:** [September 26, 2022, 3:06pm UTC](https://discourse.itk.org/t/difference-between-random-regular-and-none-sampling/5365/2 "2022-09-26T15:06:08Z")

</div>

I think that it was already discussed on this forum, that mutual information metric is not fully reproducible. It depends on the thread-related order of operations (merging results from multiple threads). I think that conclusion was that eliminating this is somewhat costly in terms of performance, and requires non-trivial engineering effort.

If you use random strategy, setting a deterministic seed should eliminate randomness from run to run. If you combine that (or regular sampling) with single thread for the metric, you should have reproducible results.

---

<div class="post-metadata">

**Author:** ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)\
**Post date:** [September 26, 2022, 3:11pm UTC](https://discourse.itk.org/t/difference-between-random-regular-and-none-sampling/5365/3 "2022-09-26T15:11:35Z")

</div>

As I recall all the sampling strategies randomly perturb the sampling point a little bit. For reproducibility the `MetricSamplingReinitializeSeed` should always be set.

---

<div class="post-metadata">

**Author:** ![cookpa](https://discourse.itk.org/user_avatar/discourse.itk.org/cookpa/32/255_2.png) [@cookpa](https://discourse.itk.org/u/cookpa)\
**Post date:** [September 27, 2022, 6:57pm UTC](https://discourse.itk.org/t/difference-between-random-regular-and-none-sampling/5365/4 "2022-09-27T18:57:06Z")

</div>

The NONE strategy does not apply a perturbation in the **itkImageRegistrationMethodv4** class, but it will still not be fully reproducible if using mutual information with multiple threads.
