[PYTHON] How to use Qubits Tomography (Make graduation research products into Buddhahood)

How to use Qubits tomography

I created Qubits Tomography in my graduation research, so I will explain how to use it. The src can be found here [https://github.com/outk/graduate_thesis). The theory of Qubit Tomography is written in the thesis. (If you feel like it, I will also summarize it on Qiita.) I also created a three-level Qutrit Tomography. If any of your readers are doing Qudit Tomography, please use it. Also, people who don't know what they're saying are good! Please press to comment. ()

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

how to use

First, copy qubit_tomo.py under your working directory (project). The directory structure is as follows.

.
└project
    └qubit_tomo.py

At the command prompt

~\project>python qubit_tomo.py

Enter.

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

Is displayed, enter the number of Qubits you want to simulate. This time I will try with four. In addition, the measurement basis is as described in the graduation thesis. Rewrite the code when measuring with other bases.

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

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

Next, enter the directory path that contains the experimental data saved in the txt file. Even if there are multiple experimental data, they will tomography all of them. However, the simulation will not proceed if the 3D drawing screen remains displayed. be careful. If you have saved the experimental data as follows, you can specify as follows.

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


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

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

Next, enter the output destination directory name of the calculation result. Anything is fine here. If nothing is entered, it will be "default". For example

------------------------------------------------------------
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

At this point, you will be asked if you want to create simulated experiment data. All inputs other than "yes" are considered "no". Pseudo-experimental data is randomly generated along the Poisson distribution with the number of times of each experimental data as the expected value.

------------------------------------------------------------
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", it will be displayed like this. Enter the experimental data ** file path ** that will be the source of the simulated experiment data. If "no", it will be skipped to the last parallelization number input. If "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

Then, you will be asked how many patterns to generate the simulated experiment data, so enter the number you want to generate.

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

Finally, you will be asked how many parallels you want to calculate. Also, the maximum number of computers currently in use that can be parallelized is displayed, so please refer to it. (** * Note: ** If it is not about half of the maximum number that can be parallelized, the CPU usage will jump up and the simulation will not proceed. After executing the simulation, be sure to check the CPU usage with a resource monitor etc. Please give me.)

------------------------------------------------------------
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 you have to do is wait for the simulation to finish. As mentioned above, other simulations will not proceed while the 3D drawing is displayed, so if you do not need it, use l.310 in src.

plotResult(numberOfQubits, estimatedDensityMatrix, baseNames)

Please comment out as follows.

#plotResult(numberOfQubits, estimatedDensityMatrix, baseNames)

Output result

The output result is saved in the following directory.

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

The fidelity with the ideal state is saved in result.txt. The ideal state is provided directly in qubit_tomo.py. Please rewrite if necessary.

Recommended Posts

How to use Qubits Tomography (Make graduation research products into Buddhahood)
How to use Qubits Tomography (my graduate product)
How to make scrapy JSON output into Japanese
How to use xml.etree.ElementTree
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 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 Decorator in Django and how to make it
How to use OptParse
How to use dotenv
How to use pyenv-virtualenv
How to use imutils
How to use import
How to use search sorted
[gensim] How to use Doc2Vec
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)
How to use Google Colaboratory
How to use Python bytes
How to make a string into an array or an array into a string in Python
How to use cron (personal memo)
How to make a Japanese-English translation
Python: How to use async with