I am trying to generate some test data.
Say I have 1000 appointments that I need to allocate over a date range.
Now I need to distribute these appointments such that there are twice as many appointments per day at the end of the month as there are at the start of the month. The increase in appointments needs to increase with a consistent velocity.
So for example if there are 5 appointments on the 1st day of the month, by the end of the month we will be getting 10 appointments per day.
An appointment can only occur on a weekday.
Is there a decent algorithm that would help me to distribute these dates in this fashion?
Edit
This is the best I got so far, inspired by Henriks solution :
private int GetNumForCurrentDate (DateTime date)
{
int daysInMonth = DateTime.DaysInMonth ( date.Year, date.Month );
// x is the number of appointments on the first day
double firstDay = this._NumPerMonth / ( ( ( ratio + 1 ) / 2 ) * daysInMonth );
// x * ratio is the number of appointments on the last day.
double lastDay = firstDay * ratio;
// Interpolate a value between the first and last days
double exactNumOnThisDay = firstDay + ( lastDay - firstDay ) * ( (double)date.Day / (double)daysInMonth );
int numOnThisDay = Convert.ToInt32 ( Math.Truncate ( exactNumOnThisDay ) );
// Accumulate any overflow
this._Overflow += exactNumOnThisDay - numOnThisDay;
if ( this._Overflow > 1 )
{
// Shove the overflow into our number when it gets into whole number teritory
numOnThisDay++;
this._Overflow--;
}
return numOnThisDay;
}
It returns the number of days to allocate on a particular day given the date. It deals with separating out the allocations to each month and handles rounding overflow, but its not quite perfect, it runs out of days to allocate on the last day, but it is good enough for now and Ive run out of time to perfect it..