# Simulating quantum coefficients

• Alex Cros

#### Alex Cros

Hi everyone,

I want to generate 8 random variables (in reality to form 4 complex numbers) such that the sum of the 8 variables squared is equal to unity. The aim of generating such numbers is to perform a quantum simulation of 4 qubits (thus the 8 parameters). I've been trying to use RandomVariate[NormalDistribution[]] in Mathematica (since the rest of the calculations are there) but I'm not quite sure how to satisfy the constraint described before. I'm not familiar with Monte-Carlo simulations.

I'm not familiar with Monte-Carlo simulations.
You will have to do something about that ...

8D is too complicated for me.

In a 3D equivalent: suppose you generate sets of 3 uniformly distributed random numbers -- i.e. a cube, uniformly filled with points. If you want the sphere ##r^2 = 1## then picking only the points that satisfy that constraint is totally inefficient. Switch to spherical coordinates and pick ##\phi## and ##\theta##: all points are on the sphere.

Alas, now they are unevenly distributed over the surface of the sphere. Easily fixed by not distributing ##\theta## itself evenly, but ##\cos\theta## instead (Something to do with ##dA = r \sin\theta \,d\theta d\phi \ ## -- check this because I quote from long term-memory that may have suffered from radiation damage ).​

And this concludes your first MC101 lesson . Homework: extrapolate to 8D .

By the way: is ##r^2 = 1## the only constraint ? And is it right to assume you want the points evenly distributed over the 7D 'sphere' ? Why do you have 'NormalDistribution' in there ?

Last edited:
• Alex Cros
I want to generate 8 random variables (in reality to form 4 complex numbers) such that the sum of the 8 variables squared is equal to unity. The aim of generating such numbers is to perform a quantum simulation of 4 qubits (thus the 8 parameters).
I don't understand what you want. Do you need to determine the state of 4 qubits, independent of each other? If that is the case, then you can use @BvU's advice and generate 4 locations on the Bloch sphere.

• Alex Cros
How about creating 8 random variables on the interval [-1,1] and then normalizing them?
##X_{i}=random(-1,1), i=1,8##
##A=\sqrt{X{_1}^2+X_{2}^2+...X_{8}^2}##
##Y_{i}=X_{i}/A##

• Alex Cros
How about creating 8 random variables on the interval [-1,1] and then normalizing them?
##X_{i}=random(-1,1), i=1,8##
##A=\sqrt{X{_1}^2+X_{2}^2+...X_{8}^2}##
##Y_{i}=X_{i}/A##
In 3D that would be projecting the 'cube' on the 'sphere' -- unevenly distributed, which may or may not be ok, depending on what it is that you do want evenly distributed...

• Alex Cros