Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

Companion to "Pfaffian Point Processes for Two Classes of Random Plane Partitions"

27669 views
1
############################################################
2
#### Rho and Generalized Rho
3
############################################################
4
5
6
def K_restriction(K, S):
7
"""
8
K_restriction(K, S)
9
10
Produces the restricted K matrix on the set of points S
11
12
Inputs:
13
K: matrix K to restrict
14
S: a list of integers (need not be ordered)
15
"""
16
17
S = [2*(s-1) for s in S]
18
S_shift = [s+1 for s in S]
19
S.extend(S_shift)
20
S.sort()
21
22
return(K[S, S])
23
24
def rho(S, K, data_type):
25
"""
26
rho(S, K, data_type)
27
28
Computes the correlation function rho of a matrix
29
K, with data type either numeric ('n') or symbolic ('s')
30
31
Inputs:
32
S: a list of integers (need not be ordered)
33
K: matrix K whose Pfaffian yields rho
34
data_type: numeric or symbolic
35
"""
36
37
if data_type == 'n':
38
n = (K.nrows() + 4)/4
39
if len(S) > n-1:
40
return(0)
41
K_restrict_S = K_restriction(K, S)
42
prob = sqrt(K_restrict_S.det())
43
return(prob)
44
45
elif data_type == 's':
46
K_restrict_S = K_restriction(K, S)
47
prob = K_restrict_S.pfaffian()
48
num = prob.numerator()
49
den = prob.denominator()
50
return(num/den)
51
52
else:
53
print("Error: rho must be given data_type 'n' or 's'")
54
return()
55
56
def rho_generalized(S, T, K, data_type):
57
"""
58
rho_generalized(S, T, K, data_type)
59
60
Computes the generalized correlation function of a matrix
61
K, with data type either numeric ('n') or symbolic ('s');
62
that is, the probability that the point process contains
63
all the points in S and none of the points in T
64
65
Inputs:
66
S: a list of integers; points to be included
67
T: a list of integers; points to be excluded
68
K: matrix K whose Pfaffian yields rho
69
data_type: numeric or symbolic
70
"""
71
72
sets_raw = Subsets(T, submultiset=True)
73
sets = sets_raw.list()
74
for subset in sets:
75
subset.extend(S)
76
77
# creates all subsets of T and takes union of S with
78
# all such subsets
79
80
prob = sum((-1)^(len(subset) - len(S)) * rho(subset, K, data_type) for subset in sets)
81
if data_type == 'n':
82
return(prob)
83
elif data_type == 's':
84
num = prob.numerator()
85
den = prob.denominator()
86
return(num/den)
87
else:
88
print("Error: rho_generalized must be given data_type 'n' or 's'")
89
return()
90
91
92
############################################################
93
#### Event Probabilities
94
############################################################
95
96
97
def first_k_vert(k, K, data_type):
98
"""
99
Computes the probability that the first k paths are
100
vertical, given an appropriate kernel K and its data
101
type 'n' or 's'
102
"""
103
104
S = [1 .. k]
105
return(rho(S, K, data_type))
106
107
def first_k_hor(k, K, data_type):
108
"""
109
Computes the probability that the first k paths are
110
horizontal, given an appropriate matrix K and its data
111
type 'n' or 's'
112
"""
113
114
S = []
115
T = [2*ii - 1 for ii in [1 .. k]]
116
return(rho_generalized(S, T, K, data_type))
117
118
def set_minus(T, S):
119
"""
120
Returns T setminus S, where T and S are lists
121
"""
122
123
T_minus_S = [t for t in T if t not in S]
124
return(T_minus_S)
125
126
def prob_path_k_hits_x(k, x, K, data_type):
127
"""
128
Computes the probability that the kth path hits
129
the endpoint with x-coordinate x, given an appropriate
130
correlation matrix K with data type 'n' or 's'
131
"""
132
133
if k == x:
134
return(first_k_vert(k, K, data_type))
135
136
lower_indices = [1 .. x-1]
137
hitting_sets = Subsets(lower_indices, k-1, submultiset=True)
138
hitting_sets = hitting_sets.list()
139
for S in hitting_sets:
140
S.append(x)
141
142
prob = sum(rho_generalized(S, set_minus([1 .. x], S), K, data_type) for S in hitting_sets)
143
if data_type == 'n':
144
return(prob)
145
elif data_type == 's':
146
num = prob.numerator()
147
den = prob.denominator()
148
return(num/den)
149
else:
150
print("Error: prob_path_k_hits_x must be given data_type 'n' or 's'")
151
152
def prob_dist_path_k(k, K, data_type):
153
"""
154
Computes the probability distribution of the endpoint
155
of the k-th path, given an appropriate correlation
156
matrix K and its data type 'n' or 's'
157
"""
158
159
dist = []
160
for x in [k .. 2*k]:
161
dist.append(prob_path_k_hits_x(k, x, K, data_type))
162
return(dist)
163