access.weights.gaussian¶
- access.weights.gaussian(sigma)[source]¶
Create a gaussian weight function, for a specified width, \(\sigma\). The mean / location parameter is assumed to be 0. Note that the standard normalization of the Gaussian, \(1 / \sqrt{2\pi\sigma^2}\), is not applied, so \(f(0) = 1\) regardless of the value of \(\sigma\). Of course, this is irrelevant if the ultimate access values are ultimately normalized.
- Parameters:
- sigmafloat
This the classical width parameter of the Gaussian / Normal distriution.
- Returns:
- weight_functionfunction
Function returning weight, for input distance or time, x.
Examples
Import the weights.
>>> from access import weights
Create a step function with thresholds at 20, 40, and 60. Travel costs are in minutes here, but the code cannot tell if you mix units!
>>> fn = weights.gaussian(sigma = 20)
>>> {v : fn(v) for v in range(0, 61, 20)} {0: 1.0, 20: 0.6065306597126334, 40: 0.1353352832366127, 60: 0.011108996538242306}
Compare this to a simpler formulation:
>>> import numpy as np >>> {x : np.exp(-x**2/2) for x in range(4)} {0: 1.0, 1: 0.6065306597126334, 2: 0.1353352832366127, 3: 0.011108996538242306}