generic_distribution#
- generic_distribution(network, func, seeds='pore.seed')[source]#
Accepts an object from the Scipy.stats submodule and returns values from the distribution for the given seeds
- Parameters:
network (OpenPNM Network object) – The network object to which this model is associated (i.e. attached). This controls the length of the calculated array(s), and also provides access to other necessary properties.
seeds (str (dict key)) – Name of the dictionary key on the target object pointing to the array containing values of eed
func (object) – An object from the scipy.stats library. Can be a ‘frozen’ object, where all the parameters were specified upon creation, or a handle to an unintialized object. In the latter case the parameters for the distribution should be provided as keyword arguments.
- Returns:
values – An ndarray of either Np or Nt length, with values taken from the supplied distribution.
- Return type:
ndarray
Examples
The following code illustrates the process of obtaining a ‘frozen’ Scipy stats object and adding it as a model:
import numpy import scipy.stats import openpnm as op import matplotlib.pyplot as plt pn = op.network.Cubic(shape=[3, 3, 3]) pn.add_model(propname='pore.seed', model=op.models.geometry.pore_seed.random) # Now retrieve the stats distribution and add to ``geo`` as a model stats_obj = scipy.stats.weibull_min(c=2, scale=.0001, loc=0) pn.add_model(propname='pore.size', model=op.models.geometry.pore_size.generic_distribution, seeds='pore.seed', func=stats_obj) plt.hist(stats_obj.ppf(q=numpy.random.rand(1000)), bins=50) plt.show()