#!/usr/bin/env perl

# Take as an input the number of accounts available on the system.
# Return one of them via a random procedure with a skew to it.
# Current, that is picking something from the first 20% of the
# accounts (the "hot" area) 80% of the time.

if ($#ARGV != 0) {
 print $#ARGV;
 print "usage: skewed-acct.pl num-accounts\n";
 die;
}

$accounts=$ARGV[0];

# TODO Make these possible to override on the command line
# Percent of the time to use a value from the hot area
$hotspot_percent=80;
# Percent of the data set to consider the hot area
$hotspot_data=20;


# First account number not considered part of the hot area
$switch_point=$accounts * $hotspot_data / 100;

if (rand(100) <= $hotspot_percent) {
  $account=1.0 + $accounts * rand() * $hotspot_data / 100.0;
  $account=int($account)
  #print "From hotspot:  ",$account,"\n";
}
else
{
  $account=1.0 + $switch_point + $accounts * rand() * (100.0 - $hotspot_data) / 100.0;
  $account=int($account)
  #print "Not from hotspot:  ",$account,"\n";
}

print $account
