24
24
25
25
26
26
27
- import numpy as np
28
- import matplotlib .pyplot as pyplot
27
+ # import numpy as np
28
+ # import matplotlib.pyplot as pyplot
29
29
30
30
31
- phase1_llc_true = np .array ([20 , 36 , 68 , 100 ])
32
- phase1_llc_false = np .array ([0 , 0 , 0 , 0 ])
33
- phase2_llc_true = np .array ([36 , 38 , 22 , 0 ])
34
- phase2_llc_false = np .array ([0 , 2 , 0 , 0 ])
35
- phase1_tc_true = np .array ([20 , 36 , 68 , 100 ])
36
- phase1_tc_false = np .array ([0 , 0 , 0 , 0 ])
37
- p_es = np .array (["0.1" , "0.05" , "0.025" , "0" ])
38
- x_axis = np .arange (len (p_es ))
31
+ # phase1_llc_true = np.array([20, 36, 68, 100])
32
+ # phase1_llc_false= np.array([0, 0, 0, 0])
33
+ # phase2_llc_true = np.array([36, 38, 22, 0])
34
+ # phase2_llc_false= np.array([0, 2, 0, 0])
35
+ # phase1_tc_true = np.array([20, 36, 68, 100])
36
+ # phase1_tc_false= np.array([0, 0, 0, 0])
37
+ # p_es = np.array(["0.1", "0.05", "0.025", "0"])
38
+ # x_axis = np.arange(len(p_es))
39
39
40
- pyplot .axhline (y = 100 , color = 'black' , linestyle = 'dashed' )
41
- pyplot .bar (x_axis - 0.15 , phase1_llc_true , 0.2 )
42
- pyplot .bar (x_axis - 0.15 , phase2_llc_true , 0.2 , bottom = phase1_llc_true )
43
- pyplot .bar (x_axis - 0.15 , phase1_llc_false , 0.2 , bottom = phase1_llc_true + phase2_llc_true )
44
- pyplot .bar (x_axis - 0.15 , phase2_llc_false , 0.2 , bottom = phase1_llc_true + phase2_llc_true + phase1_llc_false )
40
+ # pyplot.axhline(y = 100, color = 'black', linestyle = 'dashed')
41
+ # pyplot.bar(x_axis-0.15, phase1_llc_true, 0.2)
42
+ # pyplot.bar(x_axis-0.15, phase2_llc_true, 0.2, bottom = phase1_llc_true)
43
+ # pyplot.bar(x_axis-0.15, phase1_llc_false, 0.2, bottom = phase1_llc_true + phase2_llc_true)
44
+ # pyplot.bar(x_axis-0.15, phase2_llc_false, 0.2, bottom = phase1_llc_true + phase2_llc_true + phase1_llc_false)
45
45
46
- pyplot .bar (x_axis + 0.15 , phase1_tc_true , 0.2 )
47
- pyplot .bar (x_axis + 0.15 , phase1_tc_false , 0.2 , bottom = phase1_tc_true )
46
+ # pyplot.bar(x_axis+0.15, phase1_tc_true, 0.2)
47
+ # pyplot.bar(x_axis+0.15, phase1_tc_false, 0.2, bottom = phase1_tc_true)
48
48
49
- pyplot .xticks (x_axis , p_es )
50
- pyplot .legend ([ "K=100" ,"Ph.1 True (LLC)" , "Ph.2 True (LLC)" ,"Ph.1 False (LLC)" , "Ph.2 False (LLC)" , "Ph.1 True (TreeCode)" , "Ph.1 False (TreeCode)" ])
51
- pyplot .xlabel ("p_e" )
52
- pyplot .ylim ([0 ,110 ])
53
- pyplot .title ("K= 100 Linked-loop code and Tree code" )
54
- pyplot .show ()
49
+ # pyplot.xticks(x_axis, p_es)
50
+ # pyplot.legend([ "K=100","Ph.1 True (LLC)", "Ph.2 True (LLC)","Ph.1 False (LLC)", "Ph.2 False (LLC)", "Ph.1 True (TreeCode)", "Ph.1 False (TreeCode)"])
51
+ # pyplot.xlabel("p_e")
52
+ # pyplot.ylim([0,110])
53
+ # pyplot.title("K= 100 Linked-loop code and Tree code")
54
+ # pyplot.show()
55
55
56
56
57
57
58
- phase1_llc_true = np .array ([28 , 59 , 107 , 150 ])
59
- phase1_llc_false = np .array ([0 , 0 , 0 , 0 ])
60
- phase2_llc_true = np .array ([37 , 56 , 30 , 0 ])
61
- phase2_llc_false = np .array ([4 , 3 , 0 , 0 ])
62
- phase1_tc_true = np .array ([28 , 59 , 108 , 150 ])
63
- phase1_tc_false = np .array ([1 , 0 , 0 , 0 ])
58
+ # phase1_llc_true = np.array([28, 59, 107, 150])
59
+ # phase1_llc_false= np.array([0, 0, 0, 0])
60
+ # phase2_llc_true = np.array([37, 56, 30, 0])
61
+ # phase2_llc_false= np.array([4, 3, 0, 0])
62
+ # phase1_tc_true = np.array([28, 59, 108, 150])
63
+ # phase1_tc_false = np.array([1, 0, 0, 0])
64
64
65
- pyplot .axhline (y = 150 , color = 'black' , linestyle = 'dashed' )
66
- pyplot .bar (x_axis - 0.15 , phase1_llc_true , 0.2 )
67
- pyplot .bar (x_axis - 0.15 , phase2_llc_true , 0.2 , bottom = phase1_llc_true )
68
- pyplot .bar (x_axis - 0.15 , phase1_llc_false , 0.2 , bottom = phase1_llc_true + phase2_llc_true )
69
- pyplot .bar (x_axis - 0.15 , phase2_llc_false , 0.2 , bottom = phase1_llc_true + phase2_llc_true + phase1_llc_false )
65
+ # pyplot.axhline(y = 150, color = 'black', linestyle = 'dashed')
66
+ # pyplot.bar(x_axis-0.15, phase1_llc_true, 0.2)
67
+ # pyplot.bar(x_axis-0.15, phase2_llc_true, 0.2, bottom = phase1_llc_true)
68
+ # pyplot.bar(x_axis-0.15, phase1_llc_false, 0.2, bottom = phase1_llc_true + phase2_llc_true)
69
+ # pyplot.bar(x_axis-0.15, phase2_llc_false, 0.2, bottom = phase1_llc_true + phase2_llc_true + phase1_llc_false)
70
70
71
- pyplot .bar (x_axis + 0.15 , phase1_tc_true , 0.2 )
72
- pyplot .bar (x_axis + 0.15 , phase1_tc_false , 0.2 , bottom = phase1_tc_true )
71
+ # pyplot.bar(x_axis+0.15, phase1_tc_true, 0.2)
72
+ # pyplot.bar(x_axis+0.15, phase1_tc_false, 0.2, bottom = phase1_tc_true)
73
73
74
- pyplot .xticks (x_axis , p_es )
75
- pyplot .legend ([ "K=150" ,"Ph.1 True (LLC)" , "Ph.2 True (LLC)" ,"Ph.1 False (LLC)" , "Ph.2 False (LLC)" , "Ph.1 True (TreeCode)" , "Ph.1 False (TreeCode)" ])
76
- pyplot .xlabel ("p_e" )
77
- pyplot .ylim ([0 ,160 ])
78
- pyplot .title ("K= 150 Linked-loop code and Tree code" )
79
- pyplot .show ()
74
+ # pyplot.xticks(x_axis, p_es)
75
+ # pyplot.legend([ "K=150","Ph.1 True (LLC)", "Ph.2 True (LLC)","Ph.1 False (LLC)", "Ph.2 False (LLC)", "Ph.1 True (TreeCode)", "Ph.1 False (TreeCode)"])
76
+ # pyplot.xlabel("p_e")
77
+ # pyplot.ylim([0,160])
78
+ # pyplot.title("K= 150 Linked-loop code and Tree code")
79
+ # pyplot.show()
80
80
81
81
82
82
92
92
93
93
# np.random.seed(2)
94
94
# applyErrs = np.where(bernoulli.rvs(0.1, size=100))[0]
95
- # print(applyErrs)
95
+ # print(applyErrs)
96
+
97
+
98
+
99
+ import numpy as np
100
+
101
+ # create a sample 2D array
102
+ arr = np .array ([[1 , - 1 , 3 ],
103
+ [1 , 0 , - 1 ],
104
+ [7 , - 1 , 3 ]])
105
+
106
+ # count the number of -1 values in each column
107
+ counts = np .count_nonzero (arr == - 1 , axis = 0 )
108
+
109
+ # print(counts)
110
+
111
+ chosenRoot = 5
112
+ L = 16
113
+ a = np .mod (np .arange (chosenRoot , chosenRoot + L ),L )
114
+ print (a )
115
+ b = a [np .mod (np .arange (L - chosenRoot , 2 * L - chosenRoot ),L )]
116
+ print (b )
0 commit comments