Skip to content

Instantly share code, notes, and snippets.

View quantumjim's full-sized avatar

James Wootton quantumjim

View GitHub Profile
pi=3.14159265359
def cos(T):
T=T%(2*pi)
c=1
t=1
for j in range(1,16):
t=-t*T**2/(2*j*(2*j-1))
c+=t
return c
def sin(T):
class QuantumCircuit:
def __init__(c,n):
c.n=n
c.data = []
def x(c,q):
c.data.append(('r',pi,q))
def rx(c,T,q):
c.data.append(('r',T,q))
def h(c,q):
c.data.append(('h',q))
def execute(c,shots=1024,output='counts'):
p2s=['I','X','Y','Z']*(c.n==2)+['']*(c.n==1)
def j(p1,p2,q):
return (p1+p2)*(q==1)+(p2+p1)*(q==0)
from PIL import Image
import time
dark = 10
while True:
# get new this
left = {}
@quantumjim
quantumjim / LICENSE.txt
Last active April 3, 2020 12:23
Game engine with jupyter widgets
Copyright IBM - Research 2020
Apache 2.0
@quantumjim
quantumjim / biased.py
Created May 10, 2020 11:21
Testing rng
import secrets
import numpy as np
samples = 1000000
zs = 0
os = 0
number_list = []
for _ in range(samples):
@quantumjim
quantumjim / QuantumGame.ipynb
Created June 23, 2020 19:20
Quantum Game Demo
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@quantumjim
quantumjim / GraphDecoder.ipynb
Created June 24, 2020 10:32
GraphDecoder Info
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This code is licensed under the Apache License, Version 2.0. You may
obtain a copy of this license in the LICENSE.txt file in the root directory
of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
Any modifications or derivative works of this code must retain this
copyright notice, and modified files need to carry a notice indicating
that they have been altered from the originals.
from qiskit import QuantumCircuit
fromm qiskit.quantum_info import Densitymatrix
from qiskit.providers.aer.utils import insert_noise
# make a circuit (her with 2 qubits)
circ = QuantumCircuit(2)
# add a noise model to make it noisy
noise_circ = insert_noise(circuit, noise_model, transpile=True)