How to use Qubits Tomography (my graduate product)

How to use Qubits Tomography

I made Qubits Tomography as my graduate product, so I tell you how to use it. SRC is here. The theory of Qubit Tomography is written at my graduate thesis in Japanese. So if you understand it, I recommend you read reference papers. And I alse made Qutrit Tomography, which is three dimentional version of qubit. If you would like to use Qudit Tomography, please use this product. Additionally, if you can't understand these, please give it a thumbs up and comment!

As a result of this, you can get 3D graphics like this. mixed.png

How to use

At first, copy the file of "qubit_tomo.py" in current directory.
The structure of directory may be like this.

.
└project
    └qubit_tomo.py

In command prompt,

~\project>python qubit_tomo.py

enter "python qubit_tomo.py" or "python ./qubit_tomo.py".

------------------------------------------------------------
PLEASE ENTER NUMBER OF QUBITS
------------------------------------------------------------
>>

After that, like this lines are shown, please enter a number of Qubits you want to do.
In this time, I try to simulate for 4 qubits.
And the bases of measurement which I use is written in my graduate thesis.
If you want to use other bases, please rewrite bases in src directly.

 ------------------------------------------------------------
PLEASE ENTER NUMBER OF QUBITS
------------------------------------------------------------
>>
4
------------------------------------------------------------
PLEASE ENTER PATH OF EXPERIMENTAL DATA DIRECTORY

LIKE THIS >> .\datadirectory
------------------------------------------------------------
>> 

Next, please enter directory path which include experimental data files of '*.txt'.
If there are some experimental data files, this simulater can do all of them automatically.
But, while 3D graphics as a result is shown, simulater stop.
So please delete graphics to continue.
When experimental data files is like this, you can enter like this.

.
└project
    |
    ├testdata
    |  |
    |  └test.txt
    |
    └qubit_tomo.py


------------------------------------------------------------
PLEASE ENTER PATH OF EXPERIMENTAL DATA DIRECTORY

LIKE THIS >> .\datadirectory
------------------------------------------------------------
>>
./testdata

Next, please enter a name of result directory.
Any name can be acceptable if your machine allow.
If you enter nothing, the name of result directory is "default".
I try "test".

------------------------------------------------------------
PLEASE ENTER NAME OF RESULT DIRECTORY

THE RESULT DATA WILL SAVED AT
'.\result\qubit\iterative(or poisson)\{ YOUR ENTED DIRECTORY NAME }\{ EXPERIMENTAL DATA FILE NAME }_result.txt'

IF EMPTY, THE NAME OF RESULT DIRECTORY IS 'default'
------------------------------------------------------------
>>
test

After that, you need to select whether you make artificial experimental data sets or not.
When you enter only "yes", artificial experimental data sets is made and simulated.
These data sets is made following poisson distribution.

------------------------------------------------------------
PLEASE ENTER ANSWER WHETHER DO POISSON DISTRIBUTED SIMULATION
IF YOU DO, PLEASE ENTER 'yes'
IF YOU ENTER ANOTHER WORD OR EMPTY, YOUR ANSWER IS REGARED AS 'no'
------------------------------------------------------------
>>
yes
YOUR ANSWER IS: 'yes'
------------------------------------------------------------
PLEASE ENTER PATHS OF EXPERIMENTAL DATA

IF THERE ARE MULTIPLE DATA FILE YOU WANT TO TOMOGRAPHY,
ENTER ALL PATHS SEPARATED WITH SPACE.
LIKE THIS >> .\datadirectory\ex1.txt .\datadirectory\ex2.txt ...
------------------------------------------------------------
>>

If you enter "yes", you need to enter a file path of experimental data as model.
If you enter another word, your next question will be how many do parallel computing.
After "yes", for example,

YOUR ANSWER IS: 'yes'
------------------------------------------------------------
PLEASE ENTER PATHS OF EXPERIMENTAL DATA

IF THERE ARE MULTIPLE DATA FILE YOU WANT TO TOMOGRAPHY,
ENTER ALL PATHS SEPARATED WITH SPACE.
LIKE THIS >> .\datadirectory\ex1.txt .\datadirectory\ex2.txt ...
------------------------------------------------------------
>>
./testdata/test.txt

you are asked how many patterns do you make, so please enter a number you want.

------------------------------------------------------------
PLEASE ENTER ITERATION TIME OF EACH POISSON SIMULATION
------------------------------------------------------------
>>
5

Finally, you need to enter how many parallel computing you want.
And the maximum number of parallel that your computer can do is shown, so please refer it.
(※Attention: If you choose too many number of parallel, CPU can't work well. So I recommend about half of that number. And you must check your CPU working rate is proper.)

------------------------------------------------------------
HOW MANY TIMES DO YOU WANT TO PARALLELIZE?
IF THE NUMBER IS TOO LARGE, THE PARFORMANCE OF SIMULATION BECOME LOWER.
THE NUMBER OF LOGICAL PROCESSOR OF YOUR COMPUTER IS >>
6
RECOMENDED NUMBER IS LESS THAN THE ABOVE NUMBER.
------------------------------------------------------------
>>
2

All that is left is waiting for finishing simulating.
As mentioned above, whem 3D graphics is shown, simulater is stop.
So if you do not need to show this picture, please comment out of line 310 in src.

plotResult(numberOfQubits, estimatedDensityMatrix, baseNames)

Like this.

#plotResult(numberOfQubits, estimatedDensityMatrix, baseNames)

Result

The result is saved in result directory of which you enter the name.

.
└project
    |
    ├result
    |  |
    |  └qubit
    |      |
    |      ├iterative
    |      |  |
    |      |  └test
    |      |      |
    |      |      └result.txt
    |      |
    |      └poisson
    |          |
    |          └test
    |              |
    |              └result.txt
    |
    ├testdata
    |  |
    |  └test.txt
    |
    └qubit_tomo.py

In result.txt, the fidelity between result density matrix and ideal matrix which you prepared.
Ideal matrix is prepared in src directly.
So if you need, please fix your own.

Recommended Posts

How to use Qubits Tomography (my graduate product)
How to use Qubits Tomography (Make graduation research products into Buddhahood)
How to use Python-shell
How to use tf.data
How to use virtualenv
How to use Seaboan
How to use image-match
How to use shogun
How to use Pandas 2
How to use Virtualenv
How to use numpy.vectorize
How to use pytest_report_header
How to use partial
How to use Bio.Phylo
How to use SymPy
How to use x-means
How to use WikiExtractor.py
How to use IPython
How to use virtualenv
How to use Matplotlib
How to use iptables
How to use numpy
How to use TokyoTechFes2015
How to use venv
How to use dictionary {}
How to use Pyenv
How to use list []
How to use python-kabusapi
How to use OptParse
How to use return
How to use dotenv
How to use pyenv-virtualenv
How to use Go.mod
How to use imutils
How to use import
How to use Qt Designer
How to use search sorted
[gensim] How to use Doc2Vec
python3: How to use bottle (2)
Understand how to use django-filter
How to use the generator
[Python] How to use list 1
How to use FastAPI ③ OpenAPI
How to use Python argparse
How to use IPython Notebook
How to use Pandas Rolling
[Note] How to use virtualenv
How to use redis-py Dictionaries
Python: How to use pydub
[Python] How to use checkio
[Go] How to use "... (3 periods)"
How to use Django's GeoIp2
[Python] How to use input ()
How to use the decorator
[Introduction] How to use open3d
How to use Python lambda
How to use Jupyter Notebook
[Python] How to use virtualenv
python3: How to use bottle (3)
python3: How to use bottle
How to use Google Colaboratory