Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RandomNumberGeneration] New tasks: generating correlated random numbers #490

Open
tcNickolas opened this issue Sep 27, 2020 · 6 comments
Open
Assignees
Labels
help wanted Extra attention is needed

Comments

@tcNickolas
Copy link
Member

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 tcNickolas added Hacktoberfest Issues suggested for Hacktoberfest (good for beginners) help wanted Extra attention is needed labels Sep 27, 2020
@jainvasu631
Copy link
Contributor

I would love to work on this.

@tcNickolas
Copy link
Member Author

tcNickolas commented Sep 28, 2020

@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 :-))

@jainvasu631
Copy link
Contributor

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
Copy link
Contributor

jainvasu631 commented Oct 4, 2020

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.

@tcNickolas
Copy link
Member Author

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?

@jainvasu631
Copy link
Contributor

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.

@tcNickolas tcNickolas removed the Hacktoberfest Issues suggested for Hacktoberfest (good for beginners) label Nov 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants