QuantumKatas icon indicating copy to clipboard operation
QuantumKatas copied to clipboard

[RandomNumberGeneration] New tasks: generating correlated random numbers

Open tcNickolas opened this issue 3 years ago • 6 comments

The easiest way to do it is to prepare two entangled registers that will yield the necessary distribution. We'd need to focus on coming up with interesting tasks that cover different scenarios, and then use the skills the learner got from the Superposition kata.

Here is a relevant QuantumComputing StackExchange question.

tcNickolas avatar Sep 27 '20 17:09 tcNickolas

I would love to work on this.

jainvasu631 avatar Sep 27 '20 18:09 jainvasu631

@jainvasu631 Sounds good! Feel free to post the "design" before the full pull request, so that we can discuss the tasks at a high level before implementing them.

(Also, if you send the actual pull request in October, it will count for Hacktoberfest :-))

tcNickolas avatar Sep 28 '20 06:09 tcNickolas

I will probably send it in October only. I am bit busy during weekdays so I will work on the weekends. I shall try to come up with a design by the coming weekend

jainvasu631 avatar Sep 28 '20 11:09 jainvasu631

The rough idea that I worked out was a task with generates correlated random numbers. We are given the P(0), P(1) and rho representing coefficient of correlation. Based on this we need to create a state of the form a|00> + b|01> + c|10> + d|11> such that on measuring any one qubit the probabilities are P(0) and P(1). However on measurement both qubits. Their results are correlated with correlation coefficient being rho. The type of correlation coeffiecient is the standard sample coefficient defined as the ratio of covariance to product of standard deviations. I havent explicity worked out the math for a,b,c,d but it shouldn't be too hard. If this sounds right, then we can do it.

BTW since you specified correlation I have written in terms of correlation coefficient but we can also write it in terms of a given two qubit distribution where a,b,c,d are given and we just need to implement the correct entangled state. In fact we could use this task as a precursor to the one mentioned before.

New Task 1: Create 2 bit Correlated Random Number according to rho (correlation coefficient) with P(0)=P(1)=0.5 New Task 2: Create 2 bit Random Number according to prob distribution a,b,c,d New Task 3 (Adv version of Task 1): Create 2 bit Correlated Random Number according to P(0), P(1), and rho (correlation coefficient) Potential New Task 4: Create n bit Random Numbers according to prob distribution given by 2^n doubles.

Let me know your thoughts.

jainvasu631 avatar Oct 04 '20 23:10 jainvasu631

Hmm, I'm not sure how I'd approach the task if it is framed in terms of correlation coefficient - I'll admit the definition is not very fresh in my mind... If we use that, we'll need to take care to explain what it is and provide ample examples (maybe even a rewording of each task with and without it).

I was thinking about starting with tasks that are easy to explain, for example, generate two random numbers so that they always have the same (or different) parity (well, that's super easy), or generate two random numbers so that their sum modulo 3 is never 0, just to show how one can start thinking about it. After that, I think your tasks 1-3 will work great for a more formalized approach. We can probably see how complicated will that make part 2 to see whether we need harder tasks like your task 4.

What do you think?

tcNickolas avatar Oct 07 '20 00:10 tcNickolas

The common theme is that all these tasks are drifting towards using entanglement.

Task 0: Boils down generating Bell States which the readers will almost certainly be familiar with and hence I am not sure if that is necessary. Maybe expressing Task 1 in terms of a correlation coefficient is unnecessary. It can just be as easily be stated as that both bits are same with a certain given probability. However Individually they are random(P(0)=P(1)=0.5) I only used the term correlation coefficient because that's the first thing that came into my mind when correlated numbers were specified.

Moreover, as we increase the complexity of these new tasks, we seem to be moving towards tasks more suited to a Kata. If we consider all tasks on a spectrum with one end being those suited to tutorials, and the opposite end being those suited to a Kata. Task 0 firmly lies on the tutorial end. Task 1 also on the end perhaps. However, Task 2 and 3 are closer to the Kata end. Task 4 firmly belongs in a Kata. In future also, we shall be increasing the number of tasks based on RNG. Would it not be more suitable to instead create a RandomNumberGeneration Kata? Theses tasks using Entanglement could be the first section of this Kata.

The existing tutorial portion with the addition of the task specified in #489 would be limited to 1 bit random numbers or uniformly distributed random numbers. This tutorial would then serve as a pre-req for the Kata.

I am almost certainly getting ahead of myself, but let me know your thoughts. Meanwhile, I shall try to generate the basic code behind Tasks 0-4. I know Task 2 can be done essentially by using Controlled Rotation Gates. I also believe Task 4 could be done in a similar manner using the ControlledOnInt Rotation Gates.

jainvasu631 avatar Oct 07 '20 02:10 jainvasu631