Sharedmemo.ipynbOpen in CoCalc
from efprob_qu import *

# from quantum-illustrations.py *

k0=ket(0)
k0

print(type(ket(0)))
print(type(k0))

<class 'efprob_qu.State'>
--------------------------------------------------------------------------- NameError Traceback (most recent call last) <ipython-input-3-bb412b2b92a5> in <module>() 1 print(type(ket(0))) ----> 2 print(type(k0)) NameError: name 'k0' is not defined 
print(plus)
print(minus)

[[ 0.5+0.j 0.5+0.j] [ 0.5+0.j 0.5+0.j]] [[ 0.5+0.j -0.5+0.j] [-0.5+0.j 0.5+0.j]]
complex(3)

(3+0j)
complex(3,4)

(3+4j)
[1,3] /. 4

 File "<ipython-input-32-80aac62e4fb0>", line 1 [1,3] /. 4 ^ SyntaxError: invalid syntax 
array([3])

--------------------------------------------------------------------------- NameError Traceback (most recent call last) <ipython-input-36-e15615023789> in <module>() ----> 1 array([3]) NameError: name 'array' is not defined 
cflip(1.1)

--------------------------------------------------------------------------- Exception Traceback (most recent call last) <ipython-input-43-28112a5a1c6e> in <module>() ----> 1 cflip(1.1) ~/Projects/python/efprob/efprob_qu.py in cflip(r) 1100 def cflip(r): 1101 if r < 0 or r > 1: -> 1102 raise Exception('Coin flip requires a number in the unit interval') 1103 return State(np.array([[r, 0], 1104 [0, 1 - r]]), [2]) Exception: Coin flip requires a number in the unit interval 
ps341=probabilistic_state(3,4,1)
print(ps341, type(ps341))

[[ 0.375 0. 0. ] [ 0. 0.5 0. ] [ 0. 0. 0.125]] <class 'efprob_qu.State'>
print(type(cflip(0.2)))

<class 'efprob_qu.State'>
np.array([3,4,1]) / sum([3,4,1])

array([ 0.375, 0.5 , 0.125])
convex_state_sum( (0.5, ket(0)), (0.5, ket(1)))

[[ 0.5 0. ] [ 0. 0.5]]
cfflip

[[ 0.5 0. ] [ 0. 0.5]]
point_pred(0,3)

[[ 1. 0. 0.] [ 0. 0. 0.] [ 0. 0. 0.]]
State(np.array([[1,0],[0,0]]), [2,2])

[[1 0] [0 0]]