# Drawing random number from TH2

**URL:** <https://root-forum.cern.ch/t/drawing-random-number-from-th2/58539>\
**Category:** ROOT\
**Created:** [March 14, 2024, 12:26pm UTC](https://root-forum.cern.ch/t/drawing-random-number-from-th2/58539 "2024-03-14T12:26:27Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![NgJunKai](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ngjunkai/32/30046_2.png) [@NgJunKai](https://root-forum.cern.ch/u/NgJunKai)\
**Post date:** [March 14, 2024, 12:26pm UTC](https://root-forum.cern.ch/t/drawing-random-number-from-th2/58539/1 "2024-03-14T12:26:27Z")

</div>

Hi, experts,  
I know that we can draw r.v from Th1 (using inverse sampling)  
is there any equivalent for th2 ?  
FYI my th2 distribution is having some dependence structure.

* * *

_ROOT Version:_ 6.24.00 (conda)  
_Platform:_ centos  
_Compiler:_ gcc9

* * *

---

<div class="post-metadata">

**Author:** ![Danilo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/danilo/32/34528_2.png) [@Danilo](https://root-forum.cern.ch/u/Danilo)\
**Post date:** [March 14, 2024, 12:39pm UTC](https://root-forum.cern.ch/t/drawing-random-number-from-th2/58539/2 "2024-03-14T12:39:37Z")

</div>

Hello,

Have you looked into this method [ROOT: TH2 Class Reference](https://root.cern.ch/doc/master/classTH2.html#a883f419e1f6899f9c4255b458d2afe2e) ?

Cheers,  
D

---

<div class="post-metadata">

**Author:** ![NgJunKai](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ngjunkai/32/30046_2.png) [@NgJunKai](https://root-forum.cern.ch/u/NgJunKai)\
**Post date:** [March 14, 2024, 3:09pm UTC](https://root-forum.cern.ch/t/drawing-random-number-from-th2/58539/3 "2024-03-14T15:09:54Z")

</div>

yes.i also read the code.

 ![image](https://root-forum.cern.ch/uploads/default/original/3X/7/4/74c11139fdcac4c8fcb5aec8e577bc9d6cb301b7.png)  
what is the method employed in the code to draw r.v ?

---

<div class="post-metadata">

**Author:** ![Danilo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/danilo/32/34528_2.png) [@Danilo](https://root-forum.cern.ch/u/Danilo)\
**Post date:** [March 14, 2024, 3:41pm UTC](https://root-forum.cern.ch/t/drawing-random-number-from-th2/58539/4 "2024-03-14T15:41:57Z")

</div>

Hi,

Apologies, I do not understand the question.

Best,  
D

---

<div class="post-metadata">

**Author:** ![NgJunKai](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ngjunkai/32/30046_2.png) [@NgJunKai](https://root-forum.cern.ch/u/NgJunKai)\
**Post date:** [March 15, 2024, 12:10am UTC](https://root-forum.cern.ch/t/drawing-random-number-from-th2/58539/5 "2024-03-15T00:10:09Z")

</div>

sorry for ill-posted question. i updated my reply. hope that it is clear now

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [March 15, 2024, 7:19am UTC](https://root-forum.cern.ch/t/drawing-random-number-from-th2/58539/6 "2024-03-15T07:19:57Z")

</div>

Just for curiosity, what do you mean by “r.v” ? Sorry if I missed something obvious .

---

<div class="post-metadata">

**Author:** ![NgJunKai](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ngjunkai/32/30046_2.png) [@NgJunKai](https://root-forum.cern.ch/u/NgJunKai)\
**Post date:** [March 16, 2024, 2:04am UTC](https://root-forum.cern.ch/t/drawing-random-number-from-th2/58539/7 "2024-03-16T02:04:11Z")

</div>

random variable

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [March 18, 2024, 12:18pm UTC](https://root-forum.cern.ch/t/drawing-random-number-from-th2/58539/8 "2024-03-18T12:18:07Z")

</div>

You would like to know which algorithm used TH2::GetRandom2 ?  
If that’s the case, @moneta should know.

---

<div class="post-metadata">

**Author:** ![NgJunKai](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ngjunkai/32/30046_2.png) [@NgJunKai](https://root-forum.cern.ch/u/NgJunKai)\
**Post date:** [March 19, 2024, 9:20am UTC](https://root-forum.cern.ch/t/drawing-random-number-from-th2/58539/9 "2024-03-19T09:20:26Z")

</div>

actually i would like to know what algorithm has implemented in `GetRandom1/2/3`

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [March 19, 2024, 9:26am UTC](https://root-forum.cern.ch/t/drawing-random-number-from-th2/58539/10 "2024-03-19T09:26:57Z")

</div>

Ok, let’s see what @moneta will stel.

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [April 2, 2024, 9:26am UTC](https://root-forum.cern.ch/t/drawing-random-number-from-th2/58539/11 "2024-04-02T09:26:58Z")

</div>

Closed on April 2, 2024, 9:26am UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
