maxent_disaggregation.maxent_disaggregation#
Module Contents#
Functions#
|
Generate random disaggregates based on the maximum entropy principle. |
- maxent_disaggregation.maxent_disaggregation.maxent_disagg(n: int, mean_0: float, shares: numpy.ndarray | list, sd_0: float = None, min_0: float = 0, max_0: float = np.inf, sds: numpy.ndarray | list = None, log: bool = True, grad_based: bool = False, return_shares: bool = False, return_aggregate: bool = False, max_iter: int = 1000.0, suppress_warnings: bool = False, seed: int = None, **kwargs) numpy.ndarray[source]#
Generate random disaggregates based on the maximum entropy principle. Creates a random sample of disaggregates based on the information provided. The aggregate and the shares are sampled independently. The distribution from which to sample is determined internally based on the information provided by the user.
- Parameters:
n (int) – The number of samples to generate.
mean_0 – The best guess of the aggregate value.
shares – The best guesses for the shares. The sum of the shares should be 1 (unless there are NA’s). Use np.nan for NA’s.
sd_0 – The standard deviation of the aggregate value. Set to None or NA if not available.
min – The lower boundary of the aggregate value.
max – The upper boundary of the aggregate value.
sds – The standard deviations of the shares. Set to None if not available. Use np.nan for NA’s.
log – If True, the lognormal distribution is used for the aggregate value when a mean and a standard deviation are provided. If False, samples are drawn from a truncated normal distribution with optimised Gaussian parameters to fit the observed mean and standard deviation. Note that this is the general maximum entropy solution for bounded data. Default is True to use lognormal.
suppress_warnings (bool, optional) – If True, suppress warnings about sample means and standard deviations deviating from the specified values. Default is False.
seed (int, optional) – Random seed for reproducibility. Default is None.
- Returns:
sample_disagg – A 2D array of shape (n, len(shares)) containing the generated samples.
- Return type:
np.ndarray