Generate Spatial Profiles¶
Generate Spatial Profiles¶
- pref_voting.generate_spatial_profiles.generate_covariance(n_dimensions, std, rho)[source]¶
Generates a covariance matrix for a multivariate normal distribution with the given standard deviation and correlation coefficient.
- Parameters:
n_dimensions (int) – The number of dimensions.
std (float) – The standard deviation.
rho (float) – The correlation coefficient.
- Returns:
cov – The covariance matrix for a multivariate normal distribution.
- Return type:
numpy.ndarray
- pref_voting.generate_spatial_profiles.generate_spatial_profile(num_cands, num_voters, num_dims, cand_cov=None, voter_cov=None, num_profiles=1)[source]¶
Generates a spatial profile with the candidate and voter positions generated by a multivariate normal distribution with num_dims dimensions and cand_cov the covariance matrix for candidates and voter_cov the covariance matrix for voters.
- Parameters:
num_cands (int) – The number of candidates.
num_voters (int) – The number of voters.
num_dims (int) – The number of dimensions.
cand_cov (numpy.ndarray, optional) – The covariance matrix for the multivariate normal distribution for candidates. The default is None.
voter_cov (numpy.ndarray, optional) – The covariance matrix for the multivariate normal distribution for voters. The default is the identity matrix.
- Returns:
A spatial profile with the candidate and voter positions generated by a multivariate normal distribution with num_dims dimensions and cand_cov the covariance matrix for candidates and voter_cov the covariance matrix for voters.
- Return type:
Generate Spatial Profiles - Polarized¶
- pref_voting.generate_spatial_profiles.generate_spatial_profile_polarized(cand_clusters, voter_clusters, cluster_types=None, num_profiles=1)[source]¶
Generates a spatial profile with polarized clusters of candidates and voters.
- Parameters:
cand_clusters (list) – A list of tuples of the form (mean, covariance, number of candidates) for each cluster of candidates.
voter_clusters (list) – A list of tuples of the form (mean, covariance, number of voters) for each cluster of voters.
cluster_types (dict, optional) – A list of the same length as cand_cluster that associates each cluster to the type of candidate. The default is None.
num_profiles (int, optional) – The number of profiles to generate. The default is 1.
- Returns:
A spatial profile with polarized clusters of candidates and voters.
- Return type: