Search code examples
randomsocial-networkingagentusage-statistics

Distribute user active time blocks subject to total constraint


I am building an agent-based model for product usage. I am trying to develop a function to decide whether the user is using the product at a given time, while incorporating randomness.

So, say we know the user spends a total of 1 hour per day using the product, and we know the average distribution of this time (e.g., most used at 6-8pm).

How can I generate a set of usage/non-usage times (i.e., during each 10 minute block is the user active or not) while ensuring that at the end of the day the total active time sums to one hour.

In most cases I would just run the distributor without concern for the total, and then at the end normalize by making it proportional to the total target time so the total was 1 hour. However, I can't do that because time blocks must be 10 minutes. I think this is a different question because I'm really not computing time ranges, I'm computing booleans to associate with different 10 minute time blocks (e.g., the user was/was not active during a given block).

Is there a standard way to do this?


Solution

  • I did some more thinking and figured it out, if anyone else is looking at this.

    The approach to take is this: You know the allowed number n of 10-minute time blocks for a given agent.

    Iterate n times, and on each iteration select a time block out of the day subject to your activity distribution function.

    Main point is to iterate over the number of time blocks you want to place, not over the entire day.