-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo.py
More file actions
45 lines (30 loc) · 856 Bytes
/
Copy pathdemo.py
File metadata and controls
45 lines (30 loc) · 856 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Mar 12 00:09:11 2022
@author: bancal
"""
from bah import BellAtHome
### Parameters ###
# Number of rounds
n = 10000
# Maximum bias allower per individual raw random bit
epsilon = 0.2
# Number of raw random bits used to create one question
k = 1
### Script ###
# Run Alice
alice = BellAtHome(n = n, epsilon = epsilon, k = k, device='Alice')
alice.generateRandomness()
alice.computeQuestions()
alice.answerQuestions()
# Run Bob
bob = BellAtHome(n = n, epsilon = epsilon, k = k, device='Bob')
bob.generateRandomness()
bob.computeQuestions()
bob.answerQuestions()
# Check actual bias
print(f'Average bias of Alice = {alice.computeAverageBias()}')
print(f'Average bias of Bob = {bob.computeAverageBias()}')
# Compute CHSH score
print(f'Observed CHSH score = {bob.computeCHSH()}')