Difference between revisions of "RandomStateVector"
Jump to navigation
Jump to search
(Created page with "{{Function |name=RandomStateVector |desc=Generates a random pure state vector |req=MaxEntangled<br />opt_args<br />PermuteSystems<br />Swap |rel=[[RandomDe...") |
m |
||
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{Function | {{Function | ||
|name=RandomStateVector | |name=RandomStateVector | ||
− | |desc=Generates a random | + | |desc=Generates a random pure state vector |
− | | | + | |rel=[[RandomDensityMatrix]]<br />[[RandomProbabilities]]<br />[[RandomSuperoperator]]<br />[[RandomUnitary]] |
− | | | + | |cat=[[List of functions#Random_things|Random things]] |
− | |upd=November | + | |upd=November 12, 2014 |
− | |v= | + | |v=0.50}} |
− | <tt>'''RandomStateVector'''</tt> is a [[List of functions|function]] that generates a random | + | <tt>'''RandomStateVector'''</tt> is a [[List of functions|function]] that generates a random pure state vector, uniformly distributed on the unit hypersphere (sometimes said to be uniformly distributed according to Haar measure). |
==Syntax== | ==Syntax== | ||
Line 16: | Line 16: | ||
* <tt>DIM</tt>: The dimension of the Hilbert space in which <tt>V</tt> lives. If <tt>K > 0</tt> (see optional arguments below) then <tt>DIM</tt> is the local dimension rather than the total dimension. If different local dimensions are desired, <tt>DIM</tt> should be a 1-by-2 vector containing the desired local dimensions. | * <tt>DIM</tt>: The dimension of the Hilbert space in which <tt>V</tt> lives. If <tt>K > 0</tt> (see optional arguments below) then <tt>DIM</tt> is the local dimension rather than the total dimension. If different local dimensions are desired, <tt>DIM</tt> should be a 1-by-2 vector containing the desired local dimensions. | ||
* <tt>RE</tt> (optional, default 0): A flag (either 0 or 1) indicating that <tt>V</tt> should only have real entries (<tt>RE = 1</tt>) or that it is allowed to have complex entries (<tt>RE = 0</tt>). | * <tt>RE</tt> (optional, default 0): A flag (either 0 or 1) indicating that <tt>V</tt> should only have real entries (<tt>RE = 1</tt>) or that it is allowed to have complex entries (<tt>RE = 0</tt>). | ||
− | * <tt>K</tt> (optional, default 0): If equal to 0 then <tt>V</tt> will be generated without considering its [[Schmidt rank]] | + | * <tt>K</tt> (optional, default 0): If equal to 0 then <tt>V</tt> will be generated without considering its [[SchmidtRank|Schmidt rank]]. If <tt>K > 0</tt> then a random pure state with Schmidt rank ≤ <tt>K</tt> will be generated (and with probability 1, its Schmidt rank will equal <tt>K</tt>). Note that when <tt>K = 1</tt> the states on the two subsystems are generated uniformly and independently according to Haar measure on those subsystems. When <tt>K = DIM</tt>, the usual Haar measure on the total space is used. When <tt>1 < K < DIM</tt>, a natural measure that interpolates between these two extremes is used (more specifically, the direct sum of the left (similarly, right) Schmidt vectors is chosen according to Haar measure on $\mathbb{C}^K \otimes \mathbb{C}^{DIM}$). |
==Examples== | ==Examples== | ||
===A random qubit=== | ===A random qubit=== | ||
To generate a random qubit, use the following code: | To generate a random qubit, use the following code: | ||
− | < | + | <syntaxhighlight> |
>> RandomStateVector(2) | >> RandomStateVector(2) | ||
Line 28: | Line 28: | ||
-0.1025 - 0.5498i | -0.1025 - 0.5498i | ||
-0.5518 + 0.6186i | -0.5518 + 0.6186i | ||
− | </ | + | </syntaxhighlight> |
If you want it to only have real entries, set <tt>RE = 1</tt>: | If you want it to only have real entries, set <tt>RE = 1</tt>: | ||
− | < | + | <syntaxhighlight> |
>> RandomStateVector(2,1) | >> RandomStateVector(2,1) | ||
Line 38: | Line 38: | ||
-0.4487 | -0.4487 | ||
0.8937 | 0.8937 | ||
− | </ | + | </syntaxhighlight> |
===Random states with fixed Schmidt rank=== | ===Random states with fixed Schmidt rank=== | ||
− | To generate a random product | + | To generate a random product qutrit-qutrit state and verify that it is indeed a product state, use the following code: |
− | < | + | <syntaxhighlight> |
>> v = RandomStateVector(3,0,1) | >> v = RandomStateVector(3,0,1) | ||
Line 62: | Line 62: | ||
1 | 1 | ||
− | </ | + | </syntaxhighlight> |
You could create a random pure state with Schmidt rank 2 in $\mathbb{C}^3 \otimes \mathbb{C}^4$, and verify its Schmidt rank, using the following lines of code: | You could create a random pure state with Schmidt rank 2 in $\mathbb{C}^3 \otimes \mathbb{C}^4$, and verify its Schmidt rank, using the following lines of code: | ||
− | < | + | <syntaxhighlight> |
>> v = RandomStateVector([3,4],0,2) | >> v = RandomStateVector([3,4],0,2) | ||
Line 88: | Line 88: | ||
2 | 2 | ||
− | </ | + | </syntaxhighlight> |
+ | |||
+ | {{SourceCode|name=RandomStateVector}} |
Latest revision as of 21:16, 17 December 2014
RandomStateVector | |
Generates a random pure state vector | |
Other toolboxes required | none |
---|---|
Related functions | RandomDensityMatrix RandomProbabilities RandomSuperoperator RandomUnitary |
Function category | Random things |
RandomStateVector is a function that generates a random pure state vector, uniformly distributed on the unit hypersphere (sometimes said to be uniformly distributed according to Haar measure).
Syntax
- V = RandomStateVector(DIM)
- V = RandomStateVector(DIM,RE)
- V = RandomStateVector(DIM,RE,K)
Argument descriptions
- DIM: The dimension of the Hilbert space in which V lives. If K > 0 (see optional arguments below) then DIM is the local dimension rather than the total dimension. If different local dimensions are desired, DIM should be a 1-by-2 vector containing the desired local dimensions.
- RE (optional, default 0): A flag (either 0 or 1) indicating that V should only have real entries (RE = 1) or that it is allowed to have complex entries (RE = 0).
- K (optional, default 0): If equal to 0 then V will be generated without considering its Schmidt rank. If K > 0 then a random pure state with Schmidt rank ≤ K will be generated (and with probability 1, its Schmidt rank will equal K). Note that when K = 1 the states on the two subsystems are generated uniformly and independently according to Haar measure on those subsystems. When K = DIM, the usual Haar measure on the total space is used. When 1 < K < DIM, a natural measure that interpolates between these two extremes is used (more specifically, the direct sum of the left (similarly, right) Schmidt vectors is chosen according to Haar measure on $\mathbb{C}^K \otimes \mathbb{C}^{DIM}$).
Examples
A random qubit
To generate a random qubit, use the following code:
>> RandomStateVector(2)
ans =
-0.1025 - 0.5498i
-0.5518 + 0.6186i
If you want it to only have real entries, set RE = 1:
>> RandomStateVector(2,1)
ans =
-0.4487
0.8937
Random states with fixed Schmidt rank
To generate a random product qutrit-qutrit state and verify that it is indeed a product state, use the following code:
>> v = RandomStateVector(3,0,1)
v =
0.0400 - 0.3648i
0.1169 - 0.0666i
0.0465 + 0.0016i
-0.1910 + 0.0524i
-0.0566 - 0.0455i
-0.0084 - 0.0236i
-0.4407 + 0.7079i
-0.3050 + 0.0214i
-0.0936 - 0.0489i
>> SchmidtRank(v)
ans =
1
You could create a random pure state with Schmidt rank 2 in $\mathbb{C}^3 \otimes \mathbb{C}^4$, and verify its Schmidt rank, using the following lines of code:
>> v = RandomStateVector([3,4],0,2)
v =
-0.2374 + 0.1984i
0.1643 + 0.0299i
-0.0499 + 0.0376i
-0.0689 - 0.0005i
0.7740 - 0.0448i
-0.1290 - 0.2224i
-0.0514 - 0.1565i
0.2195 + 0.2478i
-0.1636 + 0.1276i
0.0581 + 0.0608i
0.0482 - 0.0178i
-0.1050 + 0.0014i
>> SchmidtRank(v,[3,4])
ans =
2
Source code
Click here to view this function's source code on github.