Geographies

pysimmmulator.geos.distribute_to_geos(mmm_input: DataFrame, geo_details: dict, random_seed: int | None = None, dist_spec: tuple[float, float] = (0.0, 0.25), media_cost_spec: tuple[float, float] = (0.0, 0.069), perf_spec: tuple[float, float] = (0.0, 0.069)) DataFrame

Distributes MMM data to supplied geographies. Allows randomization in the scale of the distributon

Parameters:
  • mmm_input (pd.DataFrame) – simulated MMM data that was generated as part of a prior process

  • geo_details (dict) – formulated dict or output of the geos creation call (ie geos(count=50))

  • random_seed (int) – random seed for rng–if needed

  • dist_spec (tuple[float, float]) – Parameters to control the normal distribution function for populations of the geographies

  • media_cost_spec (tuple[float, float]) – Parameters to control the normal distribution function for allocation of media spend across geographies

  • perf_spec (tuple[float, float]) – Parameters to control the normal distribution function for allocation of media performance across geographies

Returns:

simulated MMM data divided into geographies as specified

Return type:

(pd.DataFrame)

class pysimmmulator.geos.geos(total_population: int, random_seed: int | None = None)

Provides randomized generation of population subsets

create_geos(geo_specs: dict, universal_scale: float = 1.0) dict

Evaluates distirbution specification for each geo and returns a finalized mapping of geo names to generated population sizes.

Parameters:
  • geo_specs (Optional[dict]) – Geography names coupled with a dict of parameters for the normal distribution of that geos population (ie {“California”:{“loc”: 3.0, “scale”: 0.5}}). ‘loc’ in this case is the multiplicative bias relative to an equal apportionment of the total population.

  • universal_scale (Optional[flaot]) – Scale parameter to be used universally for all geographies. Increased value means increased spread in the distribution of all geos

Returns:

Geo names and their associated populations

Return type:

geo_details (dict)

create_random_geos(count: int = 250) dict

Generate randomly names geographies with random population distribution using a beta distribution.

Parameters:

count (int) – Number of geographies to be created