Jump to content

How to generate statistical model using an average


benphp

Recommended Posts

This may be tricky. Say I have an average - Average Income Level for Alaska = 33987.

 

I want to create a page that will generate a random income for an Alaskan, based on this average. So the majority of incomes generated would be between 30000 and 35000, but occasionally, you'd get 11000 or even 800000.

 

Any ideas?

 

Thanks!

This may be tricky. Say I have an average - Average Income Level for Alaska = 33987.

 

I want to create a page that will generate a random income for an Alaskan, based on this average. So the majority of incomes generated would be between 30000 and 35000, but occasionally, you'd get 11000 or even 800000.

 

Any ideas?

 

Thanks!

 

Depends on many things such as how often do you want to escape that +/- boundary, how large you want the inside boundary, how large you want the outside boundary

In short to answer your question without you answering my questions this is what you would do

 

$avgincome = whatever the avg income is
$innerboundary = whatever you want (the boundary will be +/- this number)
$outerboundary = whatever you want (the boundary will be +/- this number)

for($i=0;$i<however many different incomes you want to generate;$i++) {
if(rand(0,1 in however many times you want to go outside-1)){ (example: 1 in 8 times would be rand(0,7)
	echo rand((($avgincome - $innerboundary) < 0) ? '0' : ($avgincome - $outerboundary)), ($avgincome + $innerboundary));		
} else{
	echo rand((($avgincome - $outerboundary) < 0) ? '0' : ($avgincome - $outerboundary)), ($avgincome + $outerboundary));
}
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.