Companion to "Pfaffian Point Processes for Two Classes of Random Plane Partitions"
############################################################1#### Rho and Generalized Rho2############################################################345def K_restriction(K, S):6"""7K_restriction(K, S)89Produces the restricted K matrix on the set of points S1011Inputs:12K: matrix K to restrict13S: a list of integers (need not be ordered)14"""1516S = [2*(s-1) for s in S]17S_shift = [s+1 for s in S]18S.extend(S_shift)19S.sort()2021return(K[S, S])2223def rho(S, K, data_type):24"""25rho(S, K, data_type)2627Computes the correlation function rho of a matrix28K, with data type either numeric ('n') or symbolic ('s')2930Inputs:31S: a list of integers (need not be ordered)32K: matrix K whose Pfaffian yields rho33data_type: numeric or symbolic34"""3536if data_type == 'n':37n = (K.nrows() + 4)/438if len(S) > n-1:39return(0)40K_restrict_S = K_restriction(K, S)41prob = sqrt(K_restrict_S.det())42return(prob)4344elif data_type == 's':45K_restrict_S = K_restriction(K, S)46prob = K_restrict_S.pfaffian()47num = prob.numerator()48den = prob.denominator()49return(num/den)5051else:52print("Error: rho must be given data_type 'n' or 's'")53return()5455def rho_generalized(S, T, K, data_type):56"""57rho_generalized(S, T, K, data_type)5859Computes the generalized correlation function of a matrix60K, with data type either numeric ('n') or symbolic ('s');61that is, the probability that the point process contains62all the points in S and none of the points in T6364Inputs:65S: a list of integers; points to be included66T: a list of integers; points to be excluded67K: matrix K whose Pfaffian yields rho68data_type: numeric or symbolic69"""7071sets_raw = Subsets(T, submultiset=True)72sets = sets_raw.list()73for subset in sets:74subset.extend(S)7576# creates all subsets of T and takes union of S with77# all such subsets7879prob = sum((-1)^(len(subset) - len(S)) * rho(subset, K, data_type) for subset in sets)80if data_type == 'n':81return(prob)82elif data_type == 's':83num = prob.numerator()84den = prob.denominator()85return(num/den)86else:87print("Error: rho_generalized must be given data_type 'n' or 's'")88return()899091############################################################92#### Event Probabilities93############################################################949596def first_k_vert(k, K, data_type):97"""98Computes the probability that the first k paths are99vertical, given an appropriate kernel K and its data100type 'n' or 's'101"""102103S = [1 .. k]104return(rho(S, K, data_type))105106def first_k_hor(k, K, data_type):107"""108Computes the probability that the first k paths are109horizontal, given an appropriate matrix K and its data110type 'n' or 's'111"""112113S = []114T = [2*ii - 1 for ii in [1 .. k]]115return(rho_generalized(S, T, K, data_type))116117def set_minus(T, S):118"""119Returns T setminus S, where T and S are lists120"""121122T_minus_S = [t for t in T if t not in S]123return(T_minus_S)124125def prob_path_k_hits_x(k, x, K, data_type):126"""127Computes the probability that the kth path hits128the endpoint with x-coordinate x, given an appropriate129correlation matrix K with data type 'n' or 's'130"""131132if k == x:133return(first_k_vert(k, K, data_type))134135lower_indices = [1 .. x-1]136hitting_sets = Subsets(lower_indices, k-1, submultiset=True)137hitting_sets = hitting_sets.list()138for S in hitting_sets:139S.append(x)140141prob = sum(rho_generalized(S, set_minus([1 .. x], S), K, data_type) for S in hitting_sets)142if data_type == 'n':143return(prob)144elif data_type == 's':145num = prob.numerator()146den = prob.denominator()147return(num/den)148else:149print("Error: prob_path_k_hits_x must be given data_type 'n' or 's'")150151def prob_dist_path_k(k, K, data_type):152"""153Computes the probability distribution of the endpoint154of the k-th path, given an appropriate correlation155matrix K and its data type 'n' or 's'156"""157158dist = []159for x in [k .. 2*k]:160dist.append(prob_path_k_hits_x(k, x, K, data_type))161return(dist)162163