PopulationFromFile¶
-
class
svvamp.
PopulationFromFile
(file_name, relative_noise=0.0, absolute_noise=0.0)[source]¶ Population from a file.
Parameters: - file_name – – String. The name of the file.
- relative_noise – – Number.
- absolute_noise – – Number.
Returns: A
Population
object.If the file name ends with ‘.t.csv’ (t = transposed format): simple table of utilities with candidates declared in the first column and voters declared in the first row.
If the file name ends with ‘.csv’ (but not ‘.t.csv’), candidates must be declared in the first row and voters in the first column.
Otherwise, the file is considered as a PrefLib file. In that case, since information is ordinal only,
preferences_ut[v, c]
is set to the Borda score (with no vtb) minus(C - 1) / 2
. This way, utilities are between- (C - 1) / 2
and(C - 1) / 2
.To each
preferences_ut[v, c]
, a random noise is added which is drawn independently and uniformly in the interval[- relative_noise * amplitude, relative_noise * amplitude]
, whereamplitude
is the difference between the lowest and the highest utility.Another random noise is added, which is drawn independently and uniformly in the interval
[-absolute_noise, absolute_noise]
.