Distributions¶
Degree distribution sampling for the configuration model.
distributions ¶
Stub/degree distributions for network generation.
Distribution ¶
Bases: Protocol
Protocol for discrete distributions used in stub allocation.
sample ¶
Sample n values from the distribution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int
|
Number of values to sample. |
required |
rng
|
Generator
|
Random number generator. |
required |
Returns:
| Type | Description |
|---|---|
NDArray[int_]
|
Array of n non-negative integers. |
Poisson
dataclass
¶
Poisson distribution with mean mu.
Fixed
dataclass
¶
Fixed value (all nodes get the same stub count).
Empirical
dataclass
¶
Empirical distribution from observed values.
sample ¶
Sample n values with replacement from observed values.
prepare_stubs ¶
prepare_stubs(
distribution: Distribution,
n: int,
rng: Generator,
method: CorrectionMethod = "resample_one",
) -> NDArray[int_]
Sample stubs from distribution and ensure even sum.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
distribution
|
Distribution
|
Distribution to sample from. |
required |
n
|
int
|
Number of nodes. |
required |
rng
|
Generator
|
Random number generator. |
required |
method
|
CorrectionMethod
|
How to correct odd sums: - "adjust": Add or subtract 1 from a random node - "resample_one": Resample one node until sum is even - "resample_all": Resample all nodes until sum is even |
'resample_one'
|
Returns:
| Type | Description |
|---|---|
NDArray[int_]
|
Array of stub counts with even sum. |