Whats a specific problem your having?
If you need to simulate each person voting, then maybe loop through each person and do a random sort of thing. I took the time to create a presidential election simulator. The votes are in a way random but it is also built to take into account small things such as: Older people are 5% more likely to vote for McCain etc etc.
Btw, im in Australia so the fact that i know
anything about your elections is amazing.
The below will take how ever many people you want, and echo exactly who they voted for, person by person.
PHP Code:
<?php
// Assume its a two party system, with one party being 0, the other
// being 1.
// Lets assume that 20% of the population (mass) is ethnic, and studies
// show this makes them 10% more likely to vote for Obama.
// Lets assume that 30% of the population (mass) is above 60, and studies
// show this makes them 5% more likely to vote for McCain.
// Lets assume there are 10000 people in the USA, there are actually <br />
// 300,000,000 but i didnt want to destroy any servers.
// Lets assume 80% of people vote.
// Mass = Voting Population.
$countrypop = 10000;
$votingpop = $countrypop*0.80;
$mass = $votingpop;
$ethnic = $mass*0.20;
$old = $mass*0.30;
$remaining = $mass - ($ethnic+$old);
$count = 0;
$count1 = 0;
$count2 = 0;
$largecount = 0;
$person = 0;
$VotesA = 0;
$VotesB = 0;
$Person1 = "Obama";
$Person2 = "McCain";
echo("Person 1 is: ".$Person1."<br>Person 2 is: ".$Person2."<br><br>");
///
while($count<$remaining)
{
$person = rand(0,1);
$count+=1;
if ($person == 0)
{echo($count.". Voted for Obama <br>");
$VotesA+=1; }
if ($person == 1)
{echo($count.". Voted for McCain <br>");
$VotesB+=1; }
}
while($count1<$ethnic)
{
$person = rand(0,100);
$count1+=1;
if ( $person >59 )
{echo($count+$count1+$count2.". Voted for Obama <br>");
$VotesA+=1; }
if ( $person <61 )
{echo($count+$count1+$count2.". Voted for McCain <br>");
$VotesB+=1; }
}
while($count2<$old)
{
$person = rand(0,100);
$count2+=1;
if ( $person <56 )
{echo($count+$count1+$count2.". Voted for Obama <br>");
$VotesA+=1; }
if ( $person >54 )
{echo($count+$count1+$count2.". Voted for McCain <br>");
$VotesB+=1; }
}
///
echo("<br>"."Votes for ".$Person1.": ".$VotesA."<br>");
echo("<br>"."Votes for ".$Person2.": ".$VotesB."<br>");
?>
Its far from perfect and there's a bug or two, but in general, it works.