Clear Filters
Clear Filters

How to generate a random complex unitary matrix whose columns each sum up to 1

52 views (last 30 days)
Hello everyone,
basically the problem is exactly what is stated in the title. I want to create an unitary (2D) matrix of random complex numbers, such that the elements of each column of this matrix sum up to exactly 1. Is there any way to do this? As long as it's still reasonable, computation speed and/or memory usage are not that important.
Thank you to everyone trying to help!

Accepted Answer

David Goodmanson
David Goodmanson on 22 Nov 2020
Edited: David Goodmanson on 4 Dec 2020
MODIFIED to replace previous random function
Hi Michael,
here is one way. It's based on the idea that if the unitary matrix U is nxn, and onz = [1 1 1 1 1 1... ] (length n), then the sum-of-each-column condition is
[1 1 1 1 1 1... ]*U = [1 1 1 1 1 1... ]
so
n = 5;
onz = ones(1,n);
onzc = onz'; % column vector
na = null(onzc');
% construct an (n-1)x(n-1) unitary matrix by employing random numbers
% uniformly distributed on {-1, 1} x {-i, i}
h = 2*(rand(n-1,n-1) + i*rand(n-1,n-1)) -(1+i);
% method 1
[u, ~] = qr(h);
% method 2 (slower)
% [u, ~] = eig(h+h');
% construct the result
U = na*u*na' + (1/n)*onzc*onzc';
% checks, all of these should be small
U'*U -eye(size(U))
U*U' -eye(size(U))
onz*U - onz
onz*U' - onz % U' works too
  17 Comments
Bruno Luong
Bruno Luong on 5 Dec 2020
Yes I was wrong on the plateau value of qr since I though the RAND/RANDN do not have the effect, so I run my RandUnitary code and the only thing that add is phase shuffle.
Indeed the drop of plateau value is due to RAND as we both observe now. I knew RAND is not a good input at least for QR.
I'm still stumped that EIG can be somewhat pass few uniformity tests when using with RAND. I admit that I still don't fully understand it.

Sign in to comment.

More Answers (0)

Categories

Find more on Descriptive Statistics in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!