# Example 1: Default usage with 200 ballot boxes, each having 100 voters
result1 <- simulate_election(
num_ballots = 200,
num_candidates = 3,
num_groups = 5
)
# Example 2: Using a custom ballot_voters vector
result2 <- simulate_election(
num_ballots = 340,
num_candidates = 3,
num_groups = 7,
ballot_voters = rep(200, 340)
)
# Example 3: Supplying group_proportions
result3 <- simulate_election(
num_ballots = 93,
num_candidates = 3,
num_groups = 4,
group_proportions = c(0.3, 0.5, 0.1, 0.1)
)
# Example 4: Providing a user-defined prob matrix
custom_prob <- matrix(c(
0.9, 0.1,
0.4, 0.6,
0.25, 0.75,
0.32, 0.68,
0.2, 0.8
), nrow = 5, byrow = TRUE)
result4 <- simulate_election(
num_ballots = 200,
num_candidates = 2,
num_groups = 5,
lambda = 0.3,
prob = custom_prob
)
result4$real_prob == custom_prob
# The attribute of the output real_prob matches the input custom_prob.
Run the code above in your browser using DataLab