Diffusion of innovation simulation.
This simulation models the processes discussed by Abrahamson and Rosenkopf in [AR1997] and [RA1999].
Author:  Christopher Kirkos 

Date:  04/19/2011 
Version:  0.1 
Perform regression analysis on all the identified combinations of values from the [AR1997] paper (With/without boundary conditions, all/high/low network densities, full/limited to 185 peripheral ties).
This function should effectively run the necessary regression analyses to regenerate all analysis tables presented in the paper.
Regenerate experiment case log structure from output log file.
simulate runs the simulation plotstats takes a case log file (CSV) and produces a graph file (PNG) plotnetwork takes a DOT file and produces a network visualization (PNG)
Runs the initial threshold model from [AR1997]
Parameters: 


Note
“For each case, we ran 100 trials and calculated the average number of adopters in the focal and nonfocal strata” ([AR1997] p. 298)
Module to generate graph structures.
Author:  Christopher Kirkos 

Generates a coreperiphery network like the one discussed in [AR1997] using NetworkX [HSS2008].
“First set of simulations ... coreperphiphery networks with fullylinked cores ... network density was varied by varying the number of network ties beyond the core” ([AR1997] p. 297).
The core of the network is completely connected and the edges with/between the periphery are generated randomly.
Abstract base class for DISim network generators. These objects are iterators that return graph objects on each iteration.
Generator for all combinations of 2 lists where the items are not the same.
Generates the GraphViz adoption network. Optionally writes the output to DOT and/or PNG files.
This function expected the node attributes ‘adopted’ and ‘influence’ to be prepopulated. If the ‘adopted’ attribute is True, the node is given a different color, showing adoption visually. If the ‘influence’ attribute contains a list of nodes that played a role in a given node’s adoption, then the edges from those nodes to the given target node is highlighted.
Parameters: 


Returns:  pygraphviz.AGraph object augmented with style attributes. 
Draws the network to matplotlib, coloring the nodes based on adoption. Looks for the node attribute ‘adopted’. If the attribute is True, colors the node a different color, showing adoption visually. This function assumes that the node attributes have been prepopulated.
Parameters: 


Generates a coreperiphery network like the one discussed in [AR1997] using NetworkX [HSS2008].
“First set of simulations ... coreperphiphery networks with fullylinked cores ... network density was varied by varying the number of network ties beyond the core” ([AR1997] p. 297).
Parameters: 


Created on May 4, 2011
author:  Christopher Kirkos 

“In sum, we define a boundary pressure point as a concentration of social ties linking potential adopters of an innovation in one segment of a network to a potential adopter in another segment of that network.” ([AR1997] p. 300).
”... in the second set of simulations, we operationalized boundary pressure points by counting each nonfocal potential adopter that communicates with at least half of the focal potential adopters. We also tried proportions other than one half, and the results did not differ substantially.” ([AR1997] p. 300).
”...we operationalized boundary weaknesses by counting each nonfocal potential adopter that satisfied two conditions: the potential adopter had to communicate with a focal potential adopter, and it had to have assessed profits high enough such that one adoption would create enough impetus for this potential adopter to adopt” ([AR1997] p. 300).
“A boundary weakness occurs ... when potential adopter F both has ties bridging two sides of a boundary and has a low adoption threshold. A single adoption can cause such a weakly linked potential adopter to adopt...” ([AR1997] p. 300).
“In sum, we define a boundary weakness as a social tie linking a potential adopter of an innovation in one segment of a network to a potential adopter, in another segment of that network, who is highly predisposed to adopting this innovation.” ([AR1997] p. 300).
Always returns False when called (all graphs are invalid).
An abstract base class defining the structure of GraphFilter objects.
GraphFilter objects act as a callable filter for graphs. Their intent is to be used as a way to restrict the output in large simulation to only graphs with properties of interest.
The class instance itself is callable (acts like a function)
Always returns True when called (all graphs are valid).
A GraphFilter that includes only those graph that have boundary weaknesses or pressure points over a given threshold (count of # occurrences in graph > specified threshold).
Delete all entries in Weaknesses and Pressure Points Cache.
Searches a graph for nodes that match the conditions for boundary weaknesses and boundary pressure points as given by [AR1997].
Parameters: 


Returns:  A tuple of 2 lists, the first list contains the node IDs that were identified as being boundary weaknesses, the second contains node ID’s of pressure points. 
Todo
See if there’s a way to automatically determine graph ‘dirtyness’ for cache invalidation.
Created on Apr 29, 2011
Plotting for DISim.
Author:  Christopher Kirkos 

Function to generate the Core Diffusion vs Peripheral Density plot. (Basically a clone of createPeripheralDiffusionPlot)
Created on May 2, 2011
Statistic generation for DISim
Author:  Christopher Kirkos 

Calculate the density of a network with the given number of peripheral ties, core nodes, and peripheral nodes
Calculate peripheral density, which is the number of ties in the periphery divided by the number of possible ties in the periphery.
All input values are scalars, not arrays/matrices.
Parameters: 


MinMax normalization.
Parameters: 


Returns:  A copy/view of the input Array with values normalized. 
Return type:  numpy.Array 
An optimized version of calcPeripheralDensity using the numexpr module.
All input parameters are numpy Arrays.
An optimized version of minmax using numexpr.
Calculates the max number of ties for a network with given node statistics.
Total undirected simple edges = (n*(n1))/2 Total peripheral ties = ties between nodes in the periphery and themselves, AND ties between nodes in the periphery and in the core core.
Total peripheral ties is calculated as the ... Total possible ties in the network minus the total ties between core nodes.
Parameters: 


Returns:  Tuple of the number of total possible ties in the network, the total possible core ties, and the total possible peripheral ties. 
Todo
Write latex set notation to represent this calculation in the docs.
Perform Ordinary Least Squares (OLS) regression on the trial output data to determine which parameters have the most effect on the extent of peripheral diffusion.
Parameters: 


Note
The original authors only simulated with the number of peripheral ties within range [0,185]. In their second set of simulations, they performed regressions on the same simulation but split the data set by density of peripheral ties. They split it in half with the first set having density <=0.5 and the second set with records having density >0.5. This is the reasoning behind the peripheralTieRange and densityRange function parameters.
Elementwise, subtract the mean of the values from each value and divide by the standard deviation.
Parameters: 


Returns:  A copy/view of the input Array with values standardized. 
Return type:  numpy.Array 