# Problem in torontonian sampling algo

**URL:** https://discuss.pennylane.ai/t/problem-in-torontonian-sampling-algo/2292
**Category:** PennyLane Help
**Created:** [November 14, 2022, 6:41pm UTC](https://discuss.pennylane.ai/t/problem-in-torontonian-sampling-algo/2292 "2022-11-14T18:41:44Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![MUSHKAN\_SUREKA](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/mushkan_sureka/32/835_2.png) [@MUSHKAN\_SUREKA](https://discuss.pennylane.ai/u/MUSHKAN_SUREKA)
#### Post date: [November 14, 2022, 6:41pm UTC](https://discuss.pennylane.ai/t/problem-in-torontonian-sampling-algo/2292/1 "2022-11-14T18:41:44Z")

</div>

Hey! I am trying **torontonian\_sample\_graph()** and had set the cutoff to 9 but unfortunately, I only get 1 or 0 photons per output mode\*\*

G=gnp\_random\_graph(12,0.6)

A= adjacency\_matrix(G).todense()

P=torontonian\_sample\_graph(A,35,cutoff=9)

P

---

<div class="post-metadata">

### Author: ![CatalinaAlbornoz](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/catalinaalbornoz/32/1196_2.png) [@CatalinaAlbornoz](https://discuss.pennylane.ai/u/CatalinaAlbornoz)
#### Post date: [November 15, 2022, 11:24pm UTC](https://discuss.pennylane.ai/t/problem-in-torontonian-sampling-algo/2292/2 "2022-11-15T23:24:03Z")

</div>

Hi @MUSHKAN_SUREKA,

I can confirm that I also get that ‘P’ only contains ones and zeros. I’m consulting with a colleague about this. I will post a message here as soon as we have an answer.

Thank you for your question!

---

<div class="post-metadata">

### Author: ![CatalinaAlbornoz](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/catalinaalbornoz/32/1196_2.png) [@CatalinaAlbornoz](https://discuss.pennylane.ai/u/CatalinaAlbornoz)
#### Post date: [November 17, 2022, 1:46am UTC](https://discuss.pennylane.ai/t/problem-in-torontonian-sampling-algo/2292/3 "2022-11-17T01:46:54Z")

</div>

Hi @MUSHKAN_SUREKA,

I’m back with an answer! My colleague Sebastián helped me figure out the details.

The torontonian corresponds to the problem of [Gaussian Boson Sampling with threshold detectors](https://the-walrus.readthedocs.io/en/latest/gbs_sampling.html#threshold-detection-samples): these measure 0 if there’s no detection and 1 if there’s detection of something.

So the 0’s and 1’s don’t represent the number of photons per mode, they simply state whether or not something was detected.

Knowing this I would guess that you probably want to calculate the hafnian instead of the torontonian.

I hope this is helpful!
