repo
stringlengths
7
54
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
20
28.4k
docstring
stringlengths
1
46.3k
docstring_tokens
listlengths
1
1.66k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
summary
stringlengths
4
350
obf_code
stringlengths
7.85k
764k
gboeing/osmnx
osmnx/core.py
add_paths
def add_paths(G, paths, bidirectional=False): """ Add a collection of paths to the graph. Parameters ---------- G : networkx multidigraph paths : dict the paths from OSM bidirectional : bool if True, create bidirectional edges for one-way streets Returns ------- ...
python
def add_paths(G, paths, bidirectional=False): """ Add a collection of paths to the graph. Parameters ---------- G : networkx multidigraph paths : dict the paths from OSM bidirectional : bool if True, create bidirectional edges for one-way streets Returns ------- ...
[ "def", "add_paths", "(", "G", ",", "paths", ",", "bidirectional", "=", "False", ")", ":", "# the list of values OSM uses in its 'oneway' tag to denote True", "osm_oneway_values", "=", "[", "'yes'", ",", "'true'", ",", "'1'", ",", "'-1'", "]", "for", "data", "in", ...
Add a collection of paths to the graph. Parameters ---------- G : networkx multidigraph paths : dict the paths from OSM bidirectional : bool if True, create bidirectional edges for one-way streets Returns ------- None
[ "Add", "a", "collection", "of", "paths", "to", "the", "graph", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L1259-L1305
train
Adds a collection of paths to the OSM tree G.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/core.py
create_graph
def create_graph(response_jsons, name='unnamed', retain_all=False, bidirectional=False): """ Create a networkx graph from OSM data. Parameters ---------- response_jsons : list list of dicts of JSON responses from from the Overpass API name : string the name of the graph reta...
python
def create_graph(response_jsons, name='unnamed', retain_all=False, bidirectional=False): """ Create a networkx graph from OSM data. Parameters ---------- response_jsons : list list of dicts of JSON responses from from the Overpass API name : string the name of the graph reta...
[ "def", "create_graph", "(", "response_jsons", ",", "name", "=", "'unnamed'", ",", "retain_all", "=", "False", ",", "bidirectional", "=", "False", ")", ":", "log", "(", "'Creating networkx graph from downloaded OSM data...'", ")", "start_time", "=", "time", ".", "t...
Create a networkx graph from OSM data. Parameters ---------- response_jsons : list list of dicts of JSON responses from from the Overpass API name : string the name of the graph retain_all : bool if True, return the entire graph even if it is not connected bidirectional ...
[ "Create", "a", "networkx", "graph", "from", "OSM", "data", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L1308-L1371
train
Create a networkx graph from the OSM data.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/core.py
bbox_from_point
def bbox_from_point(point, distance=1000, project_utm=False, return_crs=False): """ Create a bounding box some distance in each direction (north, south, east, and west) from some (lat, lng) point. Parameters ---------- point : tuple the (lat, lon) point to create the bounding box around...
python
def bbox_from_point(point, distance=1000, project_utm=False, return_crs=False): """ Create a bounding box some distance in each direction (north, south, east, and west) from some (lat, lng) point. Parameters ---------- point : tuple the (lat, lon) point to create the bounding box around...
[ "def", "bbox_from_point", "(", "point", ",", "distance", "=", "1000", ",", "project_utm", "=", "False", ",", "return_crs", "=", "False", ")", ":", "# reverse the order of the (lat,lng) point so it is (x,y) for shapely, then", "# project to UTM and buffer in meters", "lat", ...
Create a bounding box some distance in each direction (north, south, east, and west) from some (lat, lng) point. Parameters ---------- point : tuple the (lat, lon) point to create the bounding box around distance : int how many meters the north, south, east, and west sides of the bo...
[ "Create", "a", "bounding", "box", "some", "distance", "in", "each", "direction", "(", "north", "south", "east", "and", "west", ")", "from", "some", "(", "lat", "lng", ")", "point", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L1374-L1416
train
Create a bounding box around a point
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/core.py
graph_from_bbox
def graph_from_bbox(north, south, east, west, network_type='all_private', simplify=True, retain_all=False, truncate_by_edge=False, name='unnamed', timeout=180, memory=None, max_query_area_size=50*1000*50*1000, clean_periphery=True, infrastr...
python
def graph_from_bbox(north, south, east, west, network_type='all_private', simplify=True, retain_all=False, truncate_by_edge=False, name='unnamed', timeout=180, memory=None, max_query_area_size=50*1000*50*1000, clean_periphery=True, infrastr...
[ "def", "graph_from_bbox", "(", "north", ",", "south", ",", "east", ",", "west", ",", "network_type", "=", "'all_private'", ",", "simplify", "=", "True", ",", "retain_all", "=", "False", ",", "truncate_by_edge", "=", "False", ",", "name", "=", "'unnamed'", ...
Create a networkx graph from OSM data within some bounding box. Parameters ---------- north : float northern latitude of bounding box south : float southern latitude of bounding box east : float eastern longitude of bounding box west : float western longitude of ...
[ "Create", "a", "networkx", "graph", "from", "OSM", "data", "within", "some", "bounding", "box", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L1419-L1522
train
Create a networkx graph from OSM data within some bounding box.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/core.py
graph_from_point
def graph_from_point(center_point, distance=1000, distance_type='bbox', network_type='all_private', simplify=True, retain_all=False, truncate_by_edge=False, name='unnamed', timeout=180, memory=None, max_query_area_size=50*1000*50*1000, ...
python
def graph_from_point(center_point, distance=1000, distance_type='bbox', network_type='all_private', simplify=True, retain_all=False, truncate_by_edge=False, name='unnamed', timeout=180, memory=None, max_query_area_size=50*1000*50*1000, ...
[ "def", "graph_from_point", "(", "center_point", ",", "distance", "=", "1000", ",", "distance_type", "=", "'bbox'", ",", "network_type", "=", "'all_private'", ",", "simplify", "=", "True", ",", "retain_all", "=", "False", ",", "truncate_by_edge", "=", "False", ...
Create a networkx graph from OSM data within some distance of some (lat, lon) center point. Parameters ---------- center_point : tuple the (lat, lon) central point around which to construct the graph distance : int retain only those nodes within this many meters of the center of the...
[ "Create", "a", "networkx", "graph", "from", "OSM", "data", "within", "some", "distance", "of", "some", "(", "lat", "lon", ")", "center", "point", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L1525-L1601
train
Create a networkx graph from OSM data within some distance of some center point.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/core.py
graph_from_address
def graph_from_address(address, distance=1000, distance_type='bbox', network_type='all_private', simplify=True, retain_all=False, truncate_by_edge=False, return_coords=False, name='unnamed', timeout=180, memory=None, max_query_a...
python
def graph_from_address(address, distance=1000, distance_type='bbox', network_type='all_private', simplify=True, retain_all=False, truncate_by_edge=False, return_coords=False, name='unnamed', timeout=180, memory=None, max_query_a...
[ "def", "graph_from_address", "(", "address", ",", "distance", "=", "1000", ",", "distance_type", "=", "'bbox'", ",", "network_type", "=", "'all_private'", ",", "simplify", "=", "True", ",", "retain_all", "=", "False", ",", "truncate_by_edge", "=", "False", ","...
Create a networkx graph from OSM data within some distance of some address. Parameters ---------- address : string the address to geocode and use as the central point around which to construct the graph distance : int retain only those nodes within this many meters of the center...
[ "Create", "a", "networkx", "graph", "from", "OSM", "data", "within", "some", "distance", "of", "some", "address", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L1604-L1678
train
Create a networkx graph from OSM data within some distance of some address.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/core.py
graph_from_polygon
def graph_from_polygon(polygon, network_type='all_private', simplify=True, retain_all=False, truncate_by_edge=False, name='unnamed', timeout=180, memory=None, max_query_area_size=50*1000*50*1000, clean_periphery=True, infrastruc...
python
def graph_from_polygon(polygon, network_type='all_private', simplify=True, retain_all=False, truncate_by_edge=False, name='unnamed', timeout=180, memory=None, max_query_area_size=50*1000*50*1000, clean_periphery=True, infrastruc...
[ "def", "graph_from_polygon", "(", "polygon", ",", "network_type", "=", "'all_private'", ",", "simplify", "=", "True", ",", "retain_all", "=", "False", ",", "truncate_by_edge", "=", "False", ",", "name", "=", "'unnamed'", ",", "timeout", "=", "180", ",", "mem...
Create a networkx graph from OSM data within the spatial boundaries of the passed-in shapely polygon. Parameters ---------- polygon : shapely Polygon or MultiPolygon the shape to get network data within. coordinates should be in units of latitude-longitude degrees. network_type : st...
[ "Create", "a", "networkx", "graph", "from", "OSM", "data", "within", "the", "spatial", "boundaries", "of", "the", "passed", "-", "in", "shapely", "polygon", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L1681-L1794
train
Create a networkx graph from OSM data within the specified shapely polygon.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/core.py
graph_from_place
def graph_from_place(query, network_type='all_private', simplify=True, retain_all=False, truncate_by_edge=False, name='unnamed', which_result=1, buffer_dist=None, timeout=180, memory=None, max_query_area_size=50*1000*50*1000, clean_periphery=True, ...
python
def graph_from_place(query, network_type='all_private', simplify=True, retain_all=False, truncate_by_edge=False, name='unnamed', which_result=1, buffer_dist=None, timeout=180, memory=None, max_query_area_size=50*1000*50*1000, clean_periphery=True, ...
[ "def", "graph_from_place", "(", "query", ",", "network_type", "=", "'all_private'", ",", "simplify", "=", "True", ",", "retain_all", "=", "False", ",", "truncate_by_edge", "=", "False", ",", "name", "=", "'unnamed'", ",", "which_result", "=", "1", ",", "buff...
Create a networkx graph from OSM data within the spatial boundaries of some geocodable place(s). The query must be geocodable and OSM must have polygon boundaries for the geocode result. If OSM does not have a polygon for this place, you can instead get its street network using the graph_from_address f...
[ "Create", "a", "networkx", "graph", "from", "OSM", "data", "within", "the", "spatial", "boundaries", "of", "some", "geocodable", "place", "(", "s", ")", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L1797-L1882
train
Create a networkx graph from OSM data within a given place.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/core.py
graph_from_file
def graph_from_file(filename, bidirectional=False, simplify=True, retain_all=False, name='unnamed'): """ Create a networkx graph from OSM data in an XML file. Parameters ---------- filename : string the name of a file containing OSM XML data bidirectional : bool ...
python
def graph_from_file(filename, bidirectional=False, simplify=True, retain_all=False, name='unnamed'): """ Create a networkx graph from OSM data in an XML file. Parameters ---------- filename : string the name of a file containing OSM XML data bidirectional : bool ...
[ "def", "graph_from_file", "(", "filename", ",", "bidirectional", "=", "False", ",", "simplify", "=", "True", ",", "retain_all", "=", "False", ",", "name", "=", "'unnamed'", ")", ":", "# transmogrify file of OSM XML data into JSON", "response_jsons", "=", "[", "ove...
Create a networkx graph from OSM data in an XML file. Parameters ---------- filename : string the name of a file containing OSM XML data bidirectional : bool if True, create bidirectional edges for one-way streets simplify : bool if True, simplify the graph topology reta...
[ "Create", "a", "networkx", "graph", "from", "OSM", "data", "in", "an", "XML", "file", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/core.py#L1885-L1919
train
Create a networkx graph from OSM XML data in an XML file.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/footprints.py
osm_footprints_download
def osm_footprints_download(polygon=None, north=None, south=None, east=None, west=None, footprint_type='building', timeout=180, memory=None, max_query_area_size=50*1000*50*1000): """ Download OpenStreetMap footprint data. Parameters ---------- ...
python
def osm_footprints_download(polygon=None, north=None, south=None, east=None, west=None, footprint_type='building', timeout=180, memory=None, max_query_area_size=50*1000*50*1000): """ Download OpenStreetMap footprint data. Parameters ---------- ...
[ "def", "osm_footprints_download", "(", "polygon", "=", "None", ",", "north", "=", "None", ",", "south", "=", "None", ",", "east", "=", "None", ",", "west", "=", "None", ",", "footprint_type", "=", "'building'", ",", "timeout", "=", "180", ",", "memory", ...
Download OpenStreetMap footprint data. Parameters ---------- polygon : shapely Polygon or MultiPolygon geographic shape to fetch the footprints within north : float northern latitude of bounding box south : float southern latitude of bounding box east : float eas...
[ "Download", "OpenStreetMap", "footprint", "data", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/footprints.py#L29-L141
train
Download OpenStreetMap footprints from the server.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/footprints.py
create_footprints_gdf
def create_footprints_gdf(polygon=None, north=None, south=None, east=None, west=None, footprint_type='building', retain_invalid=False): """ Get footprint data from OSM then assemble it into a GeoDataFrame. Parameters ---------- polygon : shapely Polygon or MultiPolygon ...
python
def create_footprints_gdf(polygon=None, north=None, south=None, east=None, west=None, footprint_type='building', retain_invalid=False): """ Get footprint data from OSM then assemble it into a GeoDataFrame. Parameters ---------- polygon : shapely Polygon or MultiPolygon ...
[ "def", "create_footprints_gdf", "(", "polygon", "=", "None", ",", "north", "=", "None", ",", "south", "=", "None", ",", "east", "=", "None", ",", "west", "=", "None", ",", "footprint_type", "=", "'building'", ",", "retain_invalid", "=", "False", ")", ":"...
Get footprint data from OSM then assemble it into a GeoDataFrame. Parameters ---------- polygon : shapely Polygon or MultiPolygon geographic shape to fetch the footprints within north : float northern latitude of bounding box south : float southern latitude of bounding box ...
[ "Get", "footprint", "data", "from", "OSM", "then", "assemble", "it", "into", "a", "GeoDataFrame", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/footprints.py#L144-L251
train
Create a GeoDataFrame containing the footprints from OSM.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/footprints.py
footprints_from_point
def footprints_from_point(point, distance, footprint_type='building', retain_invalid=False): """ Get footprints within some distance north, south, east, and west of a lat-long point. Parameters ---------- point : tuple a lat-long point distance : numeric distance in meters ...
python
def footprints_from_point(point, distance, footprint_type='building', retain_invalid=False): """ Get footprints within some distance north, south, east, and west of a lat-long point. Parameters ---------- point : tuple a lat-long point distance : numeric distance in meters ...
[ "def", "footprints_from_point", "(", "point", ",", "distance", ",", "footprint_type", "=", "'building'", ",", "retain_invalid", "=", "False", ")", ":", "bbox", "=", "bbox_from_point", "(", "point", "=", "point", ",", "distance", "=", "distance", ")", "north", ...
Get footprints within some distance north, south, east, and west of a lat-long point. Parameters ---------- point : tuple a lat-long point distance : numeric distance in meters footprint_type : string type of footprint to be downloaded. OSM tag key e.g. 'building', 'land...
[ "Get", "footprints", "within", "some", "distance", "north", "south", "east", "and", "west", "of", "a", "lat", "-", "long", "point", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/footprints.py#L254-L278
train
Returns a GeoDataFrame containing footprints within some distance north south east and west of a point.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/footprints.py
footprints_from_address
def footprints_from_address(address, distance, footprint_type='building', retain_invalid=False): """ Get footprints within some distance north, south, east, and west of an address. Parameters ---------- address : string the address to geocode to a lat-long point distance : numeric ...
python
def footprints_from_address(address, distance, footprint_type='building', retain_invalid=False): """ Get footprints within some distance north, south, east, and west of an address. Parameters ---------- address : string the address to geocode to a lat-long point distance : numeric ...
[ "def", "footprints_from_address", "(", "address", ",", "distance", ",", "footprint_type", "=", "'building'", ",", "retain_invalid", "=", "False", ")", ":", "# geocode the address string to a (lat, lon) point", "point", "=", "geocode", "(", "query", "=", "address", ")"...
Get footprints within some distance north, south, east, and west of an address. Parameters ---------- address : string the address to geocode to a lat-long point distance : numeric distance in meters footprint_type : string type of footprint to be downloaded. OSM tag key...
[ "Get", "footprints", "within", "some", "distance", "north", "south", "east", "and", "west", "of", "an", "address", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/footprints.py#L281-L307
train
Get footprints within some distance north south east and west of a node.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/footprints.py
footprints_from_polygon
def footprints_from_polygon(polygon, footprint_type='building', retain_invalid=False): """ Get footprints within some polygon. Parameters ---------- polygon : shapely Polygon or MultiPolygon the shape to get data within. coordinates should be in units of latitude-longitude degrees. ...
python
def footprints_from_polygon(polygon, footprint_type='building', retain_invalid=False): """ Get footprints within some polygon. Parameters ---------- polygon : shapely Polygon or MultiPolygon the shape to get data within. coordinates should be in units of latitude-longitude degrees. ...
[ "def", "footprints_from_polygon", "(", "polygon", ",", "footprint_type", "=", "'building'", ",", "retain_invalid", "=", "False", ")", ":", "return", "create_footprints_gdf", "(", "polygon", "=", "polygon", ",", "footprint_type", "=", "footprint_type", ",", "retain_i...
Get footprints within some polygon. Parameters ---------- polygon : shapely Polygon or MultiPolygon the shape to get data within. coordinates should be in units of latitude-longitude degrees. footprint_type : string type of footprint to be downloaded. OSM tag key e.g. 'building'...
[ "Get", "footprints", "within", "some", "polygon", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/footprints.py#L310-L330
train
Returns a GeoDataFrame containing footprints within some polygon.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/footprints.py
footprints_from_place
def footprints_from_place(place, footprint_type='building', retain_invalid=False): """ Get footprints within the boundaries of some place. The query must be geocodable and OSM must have polygon boundaries for the geocode result. If OSM does not have a polygon for this place, you can instead get its...
python
def footprints_from_place(place, footprint_type='building', retain_invalid=False): """ Get footprints within the boundaries of some place. The query must be geocodable and OSM must have polygon boundaries for the geocode result. If OSM does not have a polygon for this place, you can instead get its...
[ "def", "footprints_from_place", "(", "place", ",", "footprint_type", "=", "'building'", ",", "retain_invalid", "=", "False", ")", ":", "city", "=", "gdf_from_place", "(", "place", ")", "polygon", "=", "city", "[", "'geometry'", "]", ".", "iloc", "[", "0", ...
Get footprints within the boundaries of some place. The query must be geocodable and OSM must have polygon boundaries for the geocode result. If OSM does not have a polygon for this place, you can instead get its footprints using the footprints_from_address function, which geocodes the place name to a ...
[ "Get", "footprints", "within", "the", "boundaries", "of", "some", "place", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/footprints.py#L333-L360
train
Returns a list of footprints within the boundaries of some place.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/footprints.py
plot_footprints
def plot_footprints(gdf, fig=None, ax=None, figsize=None, color='#333333', bgcolor='w', set_bounds=True, bbox=None, save=False, show=True, close=False, filename='image', file_format='png', dpi=600): """ Plot a GeoDataFrame of footprints. Parameters ---------- ...
python
def plot_footprints(gdf, fig=None, ax=None, figsize=None, color='#333333', bgcolor='w', set_bounds=True, bbox=None, save=False, show=True, close=False, filename='image', file_format='png', dpi=600): """ Plot a GeoDataFrame of footprints. Parameters ---------- ...
[ "def", "plot_footprints", "(", "gdf", ",", "fig", "=", "None", ",", "ax", "=", "None", ",", "figsize", "=", "None", ",", "color", "=", "'#333333'", ",", "bgcolor", "=", "'w'", ",", "set_bounds", "=", "True", ",", "bbox", "=", "None", ",", "save", "...
Plot a GeoDataFrame of footprints. Parameters ---------- gdf : GeoDataFrame footprints fig : figure ax : axis figsize : tuple color : string the color of the footprints bgcolor : string the background color of the plot set_bounds : bool if True, set b...
[ "Plot", "a", "GeoDataFrame", "of", "footprints", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/footprints.py#L363-L442
train
Plots a GeoDataFrame of footprints.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/elevation.py
add_node_elevations
def add_node_elevations(G, api_key, max_locations_per_batch=350, pause_duration=0.02): # pragma: no cover """ Get the elevation (meters) of each node in the network and add it to the node as an attribute. Parameters ---------- G : networkx multidigraph api_key : stri...
python
def add_node_elevations(G, api_key, max_locations_per_batch=350, pause_duration=0.02): # pragma: no cover """ Get the elevation (meters) of each node in the network and add it to the node as an attribute. Parameters ---------- G : networkx multidigraph api_key : stri...
[ "def", "add_node_elevations", "(", "G", ",", "api_key", ",", "max_locations_per_batch", "=", "350", ",", "pause_duration", "=", "0.02", ")", ":", "# pragma: no cover", "# google maps elevation API endpoint", "url_template", "=", "'https://maps.googleapis.com/maps/api/elevatio...
Get the elevation (meters) of each node in the network and add it to the node as an attribute. Parameters ---------- G : networkx multidigraph api_key : string your google maps elevation API key max_locations_per_batch : int max number of coordinate pairs to submit in each API c...
[ "Get", "the", "elevation", "(", "meters", ")", "of", "each", "node", "in", "the", "network", "and", "add", "it", "to", "the", "node", "as", "an", "attribute", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/elevation.py#L20-L92
train
Add node elevations to the multidigraph G.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/elevation.py
add_edge_grades
def add_edge_grades(G, add_absolute=True): # pragma: no cover """ Get the directed grade (ie, rise over run) for each edge in the network and add it to the edge as an attribute. Nodes must have elevation attributes to use this function. Parameters ---------- G : networkx multidigraph ad...
python
def add_edge_grades(G, add_absolute=True): # pragma: no cover """ Get the directed grade (ie, rise over run) for each edge in the network and add it to the edge as an attribute. Nodes must have elevation attributes to use this function. Parameters ---------- G : networkx multidigraph ad...
[ "def", "add_edge_grades", "(", "G", ",", "add_absolute", "=", "True", ")", ":", "# pragma: no cover", "# for each edge, calculate the difference in elevation from origin to", "# destination, then divide by edge length", "for", "u", ",", "v", ",", "data", "in", "G", ".", "...
Get the directed grade (ie, rise over run) for each edge in the network and add it to the edge as an attribute. Nodes must have elevation attributes to use this function. Parameters ---------- G : networkx multidigraph add_absolute : bool if True, also add the absolute value of the grad...
[ "Get", "the", "directed", "grade", "(", "ie", "rise", "over", "run", ")", "for", "each", "edge", "in", "the", "network", "and", "add", "it", "to", "the", "edge", "as", "an", "attribute", ".", "Nodes", "must", "have", "elevation", "attributes", "to", "u...
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/elevation.py#L96-L125
train
Adds the directed grade to each edge in the network and returns the resulting networkx multidigraph.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/save_load.py
save_gdf_shapefile
def save_gdf_shapefile(gdf, filename=None, folder=None): """ Save a GeoDataFrame of place shapes or footprints as an ESRI shapefile. Parameters ---------- gdf : GeoDataFrame the gdf to be saved filename : string what to call the shapefile (file extensions are added automatic...
python
def save_gdf_shapefile(gdf, filename=None, folder=None): """ Save a GeoDataFrame of place shapes or footprints as an ESRI shapefile. Parameters ---------- gdf : GeoDataFrame the gdf to be saved filename : string what to call the shapefile (file extensions are added automatic...
[ "def", "save_gdf_shapefile", "(", "gdf", ",", "filename", "=", "None", ",", "folder", "=", "None", ")", ":", "if", "folder", "is", "None", ":", "folder", "=", "settings", ".", "data_folder", "if", "filename", "is", "None", ":", "filename", "=", "make_shp...
Save a GeoDataFrame of place shapes or footprints as an ESRI shapefile. Parameters ---------- gdf : GeoDataFrame the gdf to be saved filename : string what to call the shapefile (file extensions are added automatically) folder : string where to save the shapefile, if non...
[ "Save", "a", "GeoDataFrame", "of", "place", "shapes", "or", "footprints", "as", "an", "ESRI", "shapefile", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/save_load.py#L26-L67
train
Save a GeoDataFrame of place shapes or footprints as an ESRI shapefile.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/save_load.py
save_graph_shapefile
def save_graph_shapefile(G, filename='graph', folder=None, encoding='utf-8'): """ Save graph nodes and edges as ESRI shapefiles to disk. Parameters ---------- G : networkx multidigraph filename : string the name of the shapefiles (not including file extensions) folder : string ...
python
def save_graph_shapefile(G, filename='graph', folder=None, encoding='utf-8'): """ Save graph nodes and edges as ESRI shapefiles to disk. Parameters ---------- G : networkx multidigraph filename : string the name of the shapefiles (not including file extensions) folder : string ...
[ "def", "save_graph_shapefile", "(", "G", ",", "filename", "=", "'graph'", ",", "folder", "=", "None", ",", "encoding", "=", "'utf-8'", ")", ":", "start_time", "=", "time", ".", "time", "(", ")", "if", "folder", "is", "None", ":", "folder", "=", "settin...
Save graph nodes and edges as ESRI shapefiles to disk. Parameters ---------- G : networkx multidigraph filename : string the name of the shapefiles (not including file extensions) folder : string the folder to contain the shapefiles, if None, use default data folder encoding : s...
[ "Save", "graph", "nodes", "and", "edges", "as", "ESRI", "shapefiles", "to", "disk", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/save_load.py#L70-L144
train
Save a networkx multidigraph G as ESRI shapefiles to disk.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/save_load.py
save_graph_osm
def save_graph_osm(G, node_tags=settings.osm_xml_node_tags, node_attrs=settings.osm_xml_node_attrs, edge_tags=settings.osm_xml_way_tags, edge_attrs=settings.osm_xml_way_attrs, oneway=True, filename='graph.osm', folder=None): ...
python
def save_graph_osm(G, node_tags=settings.osm_xml_node_tags, node_attrs=settings.osm_xml_node_attrs, edge_tags=settings.osm_xml_way_tags, edge_attrs=settings.osm_xml_way_attrs, oneway=True, filename='graph.osm', folder=None): ...
[ "def", "save_graph_osm", "(", "G", ",", "node_tags", "=", "settings", ".", "osm_xml_node_tags", ",", "node_attrs", "=", "settings", ".", "osm_xml_node_attrs", ",", "edge_tags", "=", "settings", ".", "osm_xml_way_tags", ",", "edge_attrs", "=", "settings", ".", "o...
Save a graph as an OSM XML formatted file. NOTE: for very large networks this method can take upwards of 30+ minutes to finish. Parameters __________ G : networkx multidigraph or multigraph filename : string the name of the osm file (including file extension) folder : string the...
[ "Save", "a", "graph", "as", "an", "OSM", "XML", "formatted", "file", ".", "NOTE", ":", "for", "very", "large", "networks", "this", "method", "can", "take", "upwards", "of", "30", "+", "minutes", "to", "finish", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/save_load.py#L147-L235
train
Save a networkx graph as an OSM XML formatted file.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/save_load.py
save_graphml
def save_graphml(G, filename='graph.graphml', folder=None, gephi=False): """ Save graph as GraphML file to disk. Parameters ---------- G : networkx multidigraph filename : string the name of the graphml file (including file extension) folder : string the folder to contain th...
python
def save_graphml(G, filename='graph.graphml', folder=None, gephi=False): """ Save graph as GraphML file to disk. Parameters ---------- G : networkx multidigraph filename : string the name of the graphml file (including file extension) folder : string the folder to contain th...
[ "def", "save_graphml", "(", "G", ",", "filename", "=", "'graph.graphml'", ",", "folder", "=", "None", ",", "gephi", "=", "False", ")", ":", "start_time", "=", "time", ".", "time", "(", ")", "if", "folder", "is", "None", ":", "folder", "=", "settings", ...
Save graph as GraphML file to disk. Parameters ---------- G : networkx multidigraph filename : string the name of the graphml file (including file extension) folder : string the folder to contain the file, if None, use default data folder gephi : bool if True, give each ...
[ "Save", "graph", "as", "GraphML", "file", "to", "disk", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/save_load.py#L238-L306
train
Save a networkx multidigraph to disk.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/save_load.py
load_graphml
def load_graphml(filename, folder=None, node_type=int): """ Load a GraphML file from disk and convert the node/edge attributes to correct data types. Parameters ---------- filename : string the name of the graphml file (including file extension) folder : string the folder co...
python
def load_graphml(filename, folder=None, node_type=int): """ Load a GraphML file from disk and convert the node/edge attributes to correct data types. Parameters ---------- filename : string the name of the graphml file (including file extension) folder : string the folder co...
[ "def", "load_graphml", "(", "filename", ",", "folder", "=", "None", ",", "node_type", "=", "int", ")", ":", "start_time", "=", "time", ".", "time", "(", ")", "# read the graph from disk", "if", "folder", "is", "None", ":", "folder", "=", "settings", ".", ...
Load a GraphML file from disk and convert the node/edge attributes to correct data types. Parameters ---------- filename : string the name of the graphml file (including file extension) folder : string the folder containing the file, if None, use default data folder node_type : ...
[ "Load", "a", "GraphML", "file", "from", "disk", "and", "convert", "the", "node", "/", "edge", "attributes", "to", "correct", "data", "types", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/save_load.py#L309-L393
train
Load a GraphML file from disk and convert the node and edge attributes to correct data types.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/save_load.py
is_duplicate_edge
def is_duplicate_edge(data, data_other): """ Check if two edge data dictionaries are the same based on OSM ID and geometry. Parameters ---------- data : dict the first edge's data data_other : dict the second edge's data Returns ------- is_dupe : bool """ ...
python
def is_duplicate_edge(data, data_other): """ Check if two edge data dictionaries are the same based on OSM ID and geometry. Parameters ---------- data : dict the first edge's data data_other : dict the second edge's data Returns ------- is_dupe : bool """ ...
[ "def", "is_duplicate_edge", "(", "data", ",", "data_other", ")", ":", "is_dupe", "=", "False", "# if either edge's OSM ID contains multiple values (due to simplification), we want", "# to compare as sets so they are order-invariant, otherwise uv does not match vu", "osmid", "=", "set",...
Check if two edge data dictionaries are the same based on OSM ID and geometry. Parameters ---------- data : dict the first edge's data data_other : dict the second edge's data Returns ------- is_dupe : bool
[ "Check", "if", "two", "edge", "data", "dictionaries", "are", "the", "same", "based", "on", "OSM", "ID", "and", "geometry", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/save_load.py#L396-L434
train
Checks if two edge data dictionaries are the same based on OSM ID and geometry attributes.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/save_load.py
is_same_geometry
def is_same_geometry(ls1, ls2): """ Check if LineString geometries in two edges are the same, in normal or reversed order of points. Parameters ---------- ls1 : LineString the first edge's geometry ls2 : LineString the second edge's geometry Returns ------- bool...
python
def is_same_geometry(ls1, ls2): """ Check if LineString geometries in two edges are the same, in normal or reversed order of points. Parameters ---------- ls1 : LineString the first edge's geometry ls2 : LineString the second edge's geometry Returns ------- bool...
[ "def", "is_same_geometry", "(", "ls1", ",", "ls2", ")", ":", "# extract geometries from each edge data dict", "geom1", "=", "[", "list", "(", "coords", ")", "for", "coords", "in", "ls1", ".", "xy", "]", "geom2", "=", "[", "list", "(", "coords", ")", "for",...
Check if LineString geometries in two edges are the same, in normal or reversed order of points. Parameters ---------- ls1 : LineString the first edge's geometry ls2 : LineString the second edge's geometry Returns ------- bool
[ "Check", "if", "LineString", "geometries", "in", "two", "edges", "are", "the", "same", "in", "normal", "or", "reversed", "order", "of", "points", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/save_load.py#L437-L464
train
Checks if the geometries in two edges are the same in normal or reversed order of points.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/save_load.py
update_edge_keys
def update_edge_keys(G): """ Update the keys of edges that share a u, v with another edge but differ in geometry. For example, two one-way streets from u to v that bow away from each other as separate streets, rather than opposite direction edges of a single street. Parameters --------...
python
def update_edge_keys(G): """ Update the keys of edges that share a u, v with another edge but differ in geometry. For example, two one-way streets from u to v that bow away from each other as separate streets, rather than opposite direction edges of a single street. Parameters --------...
[ "def", "update_edge_keys", "(", "G", ")", ":", "# identify all the edges that are duplicates based on a sorted combination", "# of their origin, destination, and key. that is, edge uv will match edge vu", "# as a duplicate, but only if they have the same key", "edges", "=", "graph_to_gdfs", ...
Update the keys of edges that share a u, v with another edge but differ in geometry. For example, two one-way streets from u to v that bow away from each other as separate streets, rather than opposite direction edges of a single street. Parameters ---------- G : networkx multidigraph ...
[ "Update", "the", "keys", "of", "edges", "that", "share", "a", "u", "v", "with", "another", "edge", "but", "differ", "in", "geometry", ".", "For", "example", "two", "one", "-", "way", "streets", "from", "u", "to", "v", "that", "bow", "away", "from", "...
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/save_load.py#L468-L522
train
Update the keys of edges that share a u v with another edge but differ in geometry.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/save_load.py
get_undirected
def get_undirected(G): """ Convert a directed graph to an undirected graph that maintains parallel edges if geometries differ. Parameters ---------- G : networkx multidigraph Returns ------- networkx multigraph """ start_time = time.time() # set from/to nodes before m...
python
def get_undirected(G): """ Convert a directed graph to an undirected graph that maintains parallel edges if geometries differ. Parameters ---------- G : networkx multidigraph Returns ------- networkx multigraph """ start_time = time.time() # set from/to nodes before m...
[ "def", "get_undirected", "(", "G", ")", ":", "start_time", "=", "time", ".", "time", "(", ")", "# set from/to nodes before making graph undirected", "G", "=", "G", ".", "copy", "(", ")", "for", "u", ",", "v", ",", "k", ",", "data", "in", "G", ".", "edg...
Convert a directed graph to an undirected graph that maintains parallel edges if geometries differ. Parameters ---------- G : networkx multidigraph Returns ------- networkx multigraph
[ "Convert", "a", "directed", "graph", "to", "an", "undirected", "graph", "that", "maintains", "parallel", "edges", "if", "geometries", "differ", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/save_load.py#L526-L593
train
Convert a directed graph to an undirected graph that maintains parallel edges if geometries differ.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/save_load.py
graph_to_gdfs
def graph_to_gdfs(G, nodes=True, edges=True, node_geometry=True, fill_edge_geometry=True): """ Convert a graph into node and/or edge GeoDataFrames Parameters ---------- G : networkx multidigraph nodes : bool if True, convert graph nodes to a GeoDataFrame and return it edges : bool ...
python
def graph_to_gdfs(G, nodes=True, edges=True, node_geometry=True, fill_edge_geometry=True): """ Convert a graph into node and/or edge GeoDataFrames Parameters ---------- G : networkx multidigraph nodes : bool if True, convert graph nodes to a GeoDataFrame and return it edges : bool ...
[ "def", "graph_to_gdfs", "(", "G", ",", "nodes", "=", "True", ",", "edges", "=", "True", ",", "node_geometry", "=", "True", ",", "fill_edge_geometry", "=", "True", ")", ":", "if", "not", "(", "nodes", "or", "edges", ")", ":", "raise", "ValueError", "(",...
Convert a graph into node and/or edge GeoDataFrames Parameters ---------- G : networkx multidigraph nodes : bool if True, convert graph nodes to a GeoDataFrame and return it edges : bool if True, convert graph edges to a GeoDataFrame and return it node_geometry : bool if...
[ "Convert", "a", "graph", "into", "node", "and", "/", "or", "edge", "GeoDataFrames" ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/save_load.py#L596-L676
train
Convert a networkx multidigraph into a list of GeoDataFrames.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/save_load.py
gdfs_to_graph
def gdfs_to_graph(gdf_nodes, gdf_edges): """ Convert node and edge GeoDataFrames into a graph Parameters ---------- gdf_nodes : GeoDataFrame gdf_edges : GeoDataFrame Returns ------- networkx multidigraph """ G = nx.MultiDiGraph() G.graph['crs'] = gdf_nodes.crs G.gr...
python
def gdfs_to_graph(gdf_nodes, gdf_edges): """ Convert node and edge GeoDataFrames into a graph Parameters ---------- gdf_nodes : GeoDataFrame gdf_edges : GeoDataFrame Returns ------- networkx multidigraph """ G = nx.MultiDiGraph() G.graph['crs'] = gdf_nodes.crs G.gr...
[ "def", "gdfs_to_graph", "(", "gdf_nodes", ",", "gdf_edges", ")", ":", "G", "=", "nx", ".", "MultiDiGraph", "(", ")", "G", ".", "graph", "[", "'crs'", "]", "=", "gdf_nodes", ".", "crs", "G", ".", "graph", "[", "'name'", "]", "=", "gdf_nodes", ".", "...
Convert node and edge GeoDataFrames into a graph Parameters ---------- gdf_nodes : GeoDataFrame gdf_edges : GeoDataFrame Returns ------- networkx multidigraph
[ "Convert", "node", "and", "edge", "GeoDataFrames", "into", "a", "graph" ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/save_load.py#L679-L714
train
Convert node and edge GeoDataFrames into a networkx graphx object.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/save_load.py
make_shp_filename
def make_shp_filename(place_name): """ Create a filename string in a consistent format from a place name string. Parameters ---------- place_name : string place name to convert into a filename Returns ------- string """ name_pieces = list(reversed(place_name.split(', ')...
python
def make_shp_filename(place_name): """ Create a filename string in a consistent format from a place name string. Parameters ---------- place_name : string place name to convert into a filename Returns ------- string """ name_pieces = list(reversed(place_name.split(', ')...
[ "def", "make_shp_filename", "(", "place_name", ")", ":", "name_pieces", "=", "list", "(", "reversed", "(", "place_name", ".", "split", "(", "', '", ")", ")", ")", "filename", "=", "'-'", ".", "join", "(", "name_pieces", ")", ".", "lower", "(", ")", "."...
Create a filename string in a consistent format from a place name string. Parameters ---------- place_name : string place name to convert into a filename Returns ------- string
[ "Create", "a", "filename", "string", "in", "a", "consistent", "format", "from", "a", "place", "name", "string", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/save_load.py#L717-L733
train
Create a filename string from a place name string.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/stats.py
basic_stats
def basic_stats(G, area=None, clean_intersects=False, tolerance=15, circuity_dist='gc'): """ Calculate basic descriptive metric and topological stats for a graph. For an unprojected lat-lng graph, tolerance and graph units should be in degrees, and circuity_dist should be 'gc'. For a pr...
python
def basic_stats(G, area=None, clean_intersects=False, tolerance=15, circuity_dist='gc'): """ Calculate basic descriptive metric and topological stats for a graph. For an unprojected lat-lng graph, tolerance and graph units should be in degrees, and circuity_dist should be 'gc'. For a pr...
[ "def", "basic_stats", "(", "G", ",", "area", "=", "None", ",", "clean_intersects", "=", "False", ",", "tolerance", "=", "15", ",", "circuity_dist", "=", "'gc'", ")", ":", "sq_m_in_sq_km", "=", "1e6", "#there are 1 million sq meters in 1 sq km", "G_undirected", "...
Calculate basic descriptive metric and topological stats for a graph. For an unprojected lat-lng graph, tolerance and graph units should be in degrees, and circuity_dist should be 'gc'. For a projected graph, tolerance and graph units should be in meters (or similar) and circuity_dist should be 'euclid...
[ "Calculate", "basic", "descriptive", "metric", "and", "topological", "stats", "for", "a", "graph", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/stats.py#L23-L233
train
Calculates basic descriptive metric and topological stats for a single undirected network.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
gboeing/osmnx
osmnx/stats.py
extended_stats
def extended_stats(G, connectivity=False, anc=False, ecc=False, bc=False, cc=False): """ Calculate extended topological stats and metrics for a graph. Many of these algorithms have an inherently high time complexity. Global topological analysis of large complex networks is extremely time consuming ...
python
def extended_stats(G, connectivity=False, anc=False, ecc=False, bc=False, cc=False): """ Calculate extended topological stats and metrics for a graph. Many of these algorithms have an inherently high time complexity. Global topological analysis of large complex networks is extremely time consuming ...
[ "def", "extended_stats", "(", "G", ",", "connectivity", "=", "False", ",", "anc", "=", "False", ",", "ecc", "=", "False", ",", "bc", "=", "False", ",", "cc", "=", "False", ")", ":", "stats", "=", "{", "}", "full_start_time", "=", "time", ".", "time...
Calculate extended topological stats and metrics for a graph. Many of these algorithms have an inherently high time complexity. Global topological analysis of large complex networks is extremely time consuming and may exhaust computer memory. Consider using function arguments to not run metrics that re...
[ "Calculate", "extended", "topological", "stats", "and", "metrics", "for", "a", "graph", "." ]
be59fd313bcb68af8fc79242c56194f1247e26e2
https://github.com/gboeing/osmnx/blob/be59fd313bcb68af8fc79242c56194f1247e26e2/osmnx/stats.py#L236-L428
train
Calculates the extended stats and metrics for a single network.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/markov/ddp.py
backward_induction
def backward_induction(ddp, T, v_term=None): r""" Solve by backward induction a :math:`T`-period finite horizon discrete dynamic program with stationary reward and transition probability functions :math:`r` and :math:`q` and discount factor :math:`\beta \in [0, 1]`. The optimal value functions ...
python
def backward_induction(ddp, T, v_term=None): r""" Solve by backward induction a :math:`T`-period finite horizon discrete dynamic program with stationary reward and transition probability functions :math:`r` and :math:`q` and discount factor :math:`\beta \in [0, 1]`. The optimal value functions ...
[ "def", "backward_induction", "(", "ddp", ",", "T", ",", "v_term", "=", "None", ")", ":", "n", "=", "ddp", ".", "num_states", "vs", "=", "np", ".", "empty", "(", "(", "T", "+", "1", ",", "n", ")", ")", "sigmas", "=", "np", ".", "empty", "(", "...
r""" Solve by backward induction a :math:`T`-period finite horizon discrete dynamic program with stationary reward and transition probability functions :math:`r` and :math:`q` and discount factor :math:`\beta \in [0, 1]`. The optimal value functions :math:`v^*_0, \ldots, v^*_T` and policy funct...
[ "r", "Solve", "by", "backward", "induction", "a", ":", "math", ":", "T", "-", "period", "finite", "horizon", "discrete", "dynamic", "program", "with", "stationary", "reward", "and", "transition", "probability", "functions", ":", "math", ":", "r", "and", ":",...
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/markov/ddp.py#L964-L1027
train
r Solve by backward induction a : math:`T - finite horizon discrete dynamic program with stationary reward transition and probability arrays and discount factor.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/markov/ddp.py
_has_sorted_sa_indices
def _has_sorted_sa_indices(s_indices, a_indices): """ Check whether `s_indices` and `a_indices` are sorted in lexicographic order. Parameters ---------- s_indices, a_indices : ndarray(ndim=1) Returns ------- bool Whether `s_indices` and `a_indices` are sorted. """ ...
python
def _has_sorted_sa_indices(s_indices, a_indices): """ Check whether `s_indices` and `a_indices` are sorted in lexicographic order. Parameters ---------- s_indices, a_indices : ndarray(ndim=1) Returns ------- bool Whether `s_indices` and `a_indices` are sorted. """ ...
[ "def", "_has_sorted_sa_indices", "(", "s_indices", ",", "a_indices", ")", ":", "L", "=", "len", "(", "s_indices", ")", "for", "i", "in", "range", "(", "L", "-", "1", ")", ":", "if", "s_indices", "[", "i", "]", ">", "s_indices", "[", "i", "+", "1", ...
Check whether `s_indices` and `a_indices` are sorted in lexicographic order. Parameters ---------- s_indices, a_indices : ndarray(ndim=1) Returns ------- bool Whether `s_indices` and `a_indices` are sorted.
[ "Check", "whether", "s_indices", "and", "a_indices", "are", "sorted", "in", "lexicographic", "order", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/markov/ddp.py#L1074-L1096
train
Check whether s_indices and a_indices are sorted in lexicographic order.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/markov/ddp.py
_generate_a_indptr
def _generate_a_indptr(num_states, s_indices, out): """ Generate `a_indptr`; stored in `out`. `s_indices` is assumed to be in sorted order. Parameters ---------- num_states : scalar(int) s_indices : ndarray(int, ndim=1) out : ndarray(int, ndim=1) Length must be num_states+1. ...
python
def _generate_a_indptr(num_states, s_indices, out): """ Generate `a_indptr`; stored in `out`. `s_indices` is assumed to be in sorted order. Parameters ---------- num_states : scalar(int) s_indices : ndarray(int, ndim=1) out : ndarray(int, ndim=1) Length must be num_states+1. ...
[ "def", "_generate_a_indptr", "(", "num_states", ",", "s_indices", ",", "out", ")", ":", "idx", "=", "0", "out", "[", "0", "]", "=", "0", "for", "s", "in", "range", "(", "num_states", "-", "1", ")", ":", "while", "(", "s_indices", "[", "idx", "]", ...
Generate `a_indptr`; stored in `out`. `s_indices` is assumed to be in sorted order. Parameters ---------- num_states : scalar(int) s_indices : ndarray(int, ndim=1) out : ndarray(int, ndim=1) Length must be num_states+1.
[ "Generate", "a_indptr", ";", "stored", "in", "out", ".", "s_indices", "is", "assumed", "to", "be", "in", "sorted", "order", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/markov/ddp.py#L1100-L1121
train
Generate a_indptr array for the next state in the sequence s_indices.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/markov/ddp.py
DiscreteDP._check_action_feasibility
def _check_action_feasibility(self): """ Check that for every state, reward is finite for some action, and for the case sa_pair is True, that for every state, there is some action available. """ # Check that for every state, reward is finite for some action R_max...
python
def _check_action_feasibility(self): """ Check that for every state, reward is finite for some action, and for the case sa_pair is True, that for every state, there is some action available. """ # Check that for every state, reward is finite for some action R_max...
[ "def", "_check_action_feasibility", "(", "self", ")", ":", "# Check that for every state, reward is finite for some action", "R_max", "=", "self", ".", "s_wise_max", "(", "self", ".", "R", ")", "if", "(", "R_max", "==", "-", "np", ".", "inf", ")", ".", "any", ...
Check that for every state, reward is finite for some action, and for the case sa_pair is True, that for every state, there is some action available.
[ "Check", "that", "for", "every", "state", "reward", "is", "finite", "for", "some", "action", "and", "for", "the", "case", "sa_pair", "is", "True", "that", "for", "every", "state", "there", "is", "some", "action", "available", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/markov/ddp.py#L427-L453
train
Checks that the action feasibility of the action is not in use.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/markov/ddp.py
DiscreteDP.to_sa_pair_form
def to_sa_pair_form(self, sparse=True): """ Convert this instance of `DiscreteDP` to SA-pair form Parameters ---------- sparse : bool, optional(default=True) Should the `Q` matrix be stored as a sparse matrix? If true the CSR format is used Retur...
python
def to_sa_pair_form(self, sparse=True): """ Convert this instance of `DiscreteDP` to SA-pair form Parameters ---------- sparse : bool, optional(default=True) Should the `Q` matrix be stored as a sparse matrix? If true the CSR format is used Retur...
[ "def", "to_sa_pair_form", "(", "self", ",", "sparse", "=", "True", ")", ":", "if", "self", ".", "_sa_pair", ":", "return", "self", "else", ":", "s_ind", ",", "a_ind", "=", "np", ".", "where", "(", "self", ".", "R", ">", "-", "np", ".", "inf", ")"...
Convert this instance of `DiscreteDP` to SA-pair form Parameters ---------- sparse : bool, optional(default=True) Should the `Q` matrix be stored as a sparse matrix? If true the CSR format is used Returns ------- ddp_sa : DiscreteDP T...
[ "Convert", "this", "instance", "of", "DiscreteDP", "to", "SA", "-", "pair", "form" ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/markov/ddp.py#L455-L485
train
Convert this instance of DiscreteDP to SA - pair form.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/markov/ddp.py
DiscreteDP.to_product_form
def to_product_form(self): """ Convert this instance of `DiscreteDP` to the "product" form. The product form uses the version of the init method taking `R`, `Q` and `beta`. Parameters ---------- Returns ------- ddp_sa : DiscreteDP Th...
python
def to_product_form(self): """ Convert this instance of `DiscreteDP` to the "product" form. The product form uses the version of the init method taking `R`, `Q` and `beta`. Parameters ---------- Returns ------- ddp_sa : DiscreteDP Th...
[ "def", "to_product_form", "(", "self", ")", ":", "if", "self", ".", "_sa_pair", ":", "ns", "=", "self", ".", "num_states", "na", "=", "self", ".", "a_indices", ".", "max", "(", ")", "+", "1", "R", "=", "np", ".", "full", "(", "(", "ns", ",", "n...
Convert this instance of `DiscreteDP` to the "product" form. The product form uses the version of the init method taking `R`, `Q` and `beta`. Parameters ---------- Returns ------- ddp_sa : DiscreteDP The correspnoding DiscreteDP instance in product ...
[ "Convert", "this", "instance", "of", "DiscreteDP", "to", "the", "product", "form", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/markov/ddp.py#L487-L521
train
Convert this instance of DiscreteDP to the product form.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/markov/ddp.py
DiscreteDP.RQ_sigma
def RQ_sigma(self, sigma): """ Given a policy `sigma`, return the reward vector `R_sigma` and the transition probability matrix `Q_sigma`. Parameters ---------- sigma : array_like(int, ndim=1) Policy vector, of length n. Returns ------- ...
python
def RQ_sigma(self, sigma): """ Given a policy `sigma`, return the reward vector `R_sigma` and the transition probability matrix `Q_sigma`. Parameters ---------- sigma : array_like(int, ndim=1) Policy vector, of length n. Returns ------- ...
[ "def", "RQ_sigma", "(", "self", ",", "sigma", ")", ":", "if", "self", ".", "_sa_pair", ":", "sigma", "=", "np", ".", "asarray", "(", "sigma", ")", "sigma_indices", "=", "np", ".", "empty", "(", "self", ".", "num_states", ",", "dtype", "=", "int", "...
Given a policy `sigma`, return the reward vector `R_sigma` and the transition probability matrix `Q_sigma`. Parameters ---------- sigma : array_like(int, ndim=1) Policy vector, of length n. Returns ------- R_sigma : ndarray(float, ndim=1) ...
[ "Given", "a", "policy", "sigma", "return", "the", "reward", "vector", "R_sigma", "and", "the", "transition", "probability", "matrix", "Q_sigma", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/markov/ddp.py#L523-L552
train
Given a policy vector sigma return the reward vector R_sigma and transition probability matrix Q_sigma.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/markov/ddp.py
DiscreteDP.bellman_operator
def bellman_operator(self, v, Tv=None, sigma=None): """ The Bellman operator, which computes and returns the updated value function `Tv` for a value function `v`. Parameters ---------- v : array_like(float, ndim=1) Value function vector, of length n. ...
python
def bellman_operator(self, v, Tv=None, sigma=None): """ The Bellman operator, which computes and returns the updated value function `Tv` for a value function `v`. Parameters ---------- v : array_like(float, ndim=1) Value function vector, of length n. ...
[ "def", "bellman_operator", "(", "self", ",", "v", ",", "Tv", "=", "None", ",", "sigma", "=", "None", ")", ":", "vals", "=", "self", ".", "R", "+", "self", ".", "beta", "*", "self", ".", "Q", ".", "dot", "(", "v", ")", "# Shape: (L,) or (n, m)", "...
The Bellman operator, which computes and returns the updated value function `Tv` for a value function `v`. Parameters ---------- v : array_like(float, ndim=1) Value function vector, of length n. Tv : ndarray(float, ndim=1), optional(default=None) Optiona...
[ "The", "Bellman", "operator", "which", "computes", "and", "returns", "the", "updated", "value", "function", "Tv", "for", "a", "value", "function", "v", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/markov/ddp.py#L554-L582
train
This is the Bellman operator which computes and returns the updated value function Tv for a value function v.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/markov/ddp.py
DiscreteDP.T_sigma
def T_sigma(self, sigma): """ Given a policy `sigma`, return the T_sigma operator. Parameters ---------- sigma : array_like(int, ndim=1) Policy vector, of length n. Returns ------- callable The T_sigma operator. """ ...
python
def T_sigma(self, sigma): """ Given a policy `sigma`, return the T_sigma operator. Parameters ---------- sigma : array_like(int, ndim=1) Policy vector, of length n. Returns ------- callable The T_sigma operator. """ ...
[ "def", "T_sigma", "(", "self", ",", "sigma", ")", ":", "R_sigma", ",", "Q_sigma", "=", "self", ".", "RQ_sigma", "(", "sigma", ")", "return", "lambda", "v", ":", "R_sigma", "+", "self", ".", "beta", "*", "Q_sigma", ".", "dot", "(", "v", ")" ]
Given a policy `sigma`, return the T_sigma operator. Parameters ---------- sigma : array_like(int, ndim=1) Policy vector, of length n. Returns ------- callable The T_sigma operator.
[ "Given", "a", "policy", "sigma", "return", "the", "T_sigma", "operator", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/markov/ddp.py#L584-L600
train
Returns a function that returns the T_sigma operator.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/markov/ddp.py
DiscreteDP.compute_greedy
def compute_greedy(self, v, sigma=None): """ Compute the v-greedy policy. Parameters ---------- v : array_like(float, ndim=1) Value function vector, of length n. sigma : ndarray(int, ndim=1), optional(default=None) Optional output array for `sigm...
python
def compute_greedy(self, v, sigma=None): """ Compute the v-greedy policy. Parameters ---------- v : array_like(float, ndim=1) Value function vector, of length n. sigma : ndarray(int, ndim=1), optional(default=None) Optional output array for `sigm...
[ "def", "compute_greedy", "(", "self", ",", "v", ",", "sigma", "=", "None", ")", ":", "if", "sigma", "is", "None", ":", "sigma", "=", "np", ".", "empty", "(", "self", ".", "num_states", ",", "dtype", "=", "int", ")", "self", ".", "bellman_operator", ...
Compute the v-greedy policy. Parameters ---------- v : array_like(float, ndim=1) Value function vector, of length n. sigma : ndarray(int, ndim=1), optional(default=None) Optional output array for `sigma`. Returns ------- sigma : ndarray(...
[ "Compute", "the", "v", "-", "greedy", "policy", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/markov/ddp.py#L602-L623
train
Compute the v - greedy policy.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/markov/ddp.py
DiscreteDP.evaluate_policy
def evaluate_policy(self, sigma): """ Compute the value of a policy. Parameters ---------- sigma : array_like(int, ndim=1) Policy vector, of length n. Returns ------- v_sigma : ndarray(float, ndim=1) Value vector of `sigma`, of le...
python
def evaluate_policy(self, sigma): """ Compute the value of a policy. Parameters ---------- sigma : array_like(int, ndim=1) Policy vector, of length n. Returns ------- v_sigma : ndarray(float, ndim=1) Value vector of `sigma`, of le...
[ "def", "evaluate_policy", "(", "self", ",", "sigma", ")", ":", "if", "self", ".", "beta", "==", "1", ":", "raise", "NotImplementedError", "(", "self", ".", "_error_msg_no_discounting", ")", "# Solve (I - beta * Q_sigma) v = R_sigma for v", "R_sigma", ",", "Q_sigma",...
Compute the value of a policy. Parameters ---------- sigma : array_like(int, ndim=1) Policy vector, of length n. Returns ------- v_sigma : ndarray(float, ndim=1) Value vector of `sigma`, of length n.
[ "Compute", "the", "value", "of", "a", "policy", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/markov/ddp.py#L625-L651
train
Evaluate the value of a policy.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/markov/ddp.py
DiscreteDP.operator_iteration
def operator_iteration(self, T, v, max_iter, tol=None, *args, **kwargs): """ Iteratively apply the operator `T` to `v`. Modify `v` in-place. Iteration is performed for at most a number `max_iter` of times. If `tol` is specified, it is terminated once the distance of `T(v)` from `...
python
def operator_iteration(self, T, v, max_iter, tol=None, *args, **kwargs): """ Iteratively apply the operator `T` to `v`. Modify `v` in-place. Iteration is performed for at most a number `max_iter` of times. If `tol` is specified, it is terminated once the distance of `T(v)` from `...
[ "def", "operator_iteration", "(", "self", ",", "T", ",", "v", ",", "max_iter", ",", "tol", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# May be replaced with quantecon.compute_fixed_point", "if", "max_iter", "<=", "0", ":", "return", ...
Iteratively apply the operator `T` to `v`. Modify `v` in-place. Iteration is performed for at most a number `max_iter` of times. If `tol` is specified, it is terminated once the distance of `T(v)` from `v` (in the max norm) is less than `tol`. Parameters ---------- T : c...
[ "Iteratively", "apply", "the", "operator", "T", "to", "v", ".", "Modify", "v", "in", "-", "place", ".", "Iteration", "is", "performed", "for", "at", "most", "a", "number", "max_iter", "of", "times", ".", "If", "tol", "is", "specified", "it", "is", "ter...
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/markov/ddp.py#L653-L697
train
Iteratively apply the operator T to v.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/markov/ddp.py
DiscreteDP.solve
def solve(self, method='policy_iteration', v_init=None, epsilon=None, max_iter=None, k=20): """ Solve the dynamic programming problem. Parameters ---------- method : str, optinal(default='policy_iteration') Solution method, str in {'value_iteration', 'v...
python
def solve(self, method='policy_iteration', v_init=None, epsilon=None, max_iter=None, k=20): """ Solve the dynamic programming problem. Parameters ---------- method : str, optinal(default='policy_iteration') Solution method, str in {'value_iteration', 'v...
[ "def", "solve", "(", "self", ",", "method", "=", "'policy_iteration'", ",", "v_init", "=", "None", ",", "epsilon", "=", "None", ",", "max_iter", "=", "None", ",", "k", "=", "20", ")", ":", "if", "method", "in", "[", "'value_iteration'", ",", "'vi'", ...
Solve the dynamic programming problem. Parameters ---------- method : str, optinal(default='policy_iteration') Solution method, str in {'value_iteration', 'vi', 'policy_iteration', 'pi', 'modified_policy_iteration', 'mpi'}. v_init : array_like(float,...
[ "Solve", "the", "dynamic", "programming", "problem", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/markov/ddp.py#L699-L752
train
Solve the dynamic programming problem.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/markov/ddp.py
DiscreteDP.value_iteration
def value_iteration(self, v_init=None, epsilon=None, max_iter=None): """ Solve the optimization problem by value iteration. See the `solve` method. """ if self.beta == 1: raise NotImplementedError(self._error_msg_no_discounting) if max_iter is None: ...
python
def value_iteration(self, v_init=None, epsilon=None, max_iter=None): """ Solve the optimization problem by value iteration. See the `solve` method. """ if self.beta == 1: raise NotImplementedError(self._error_msg_no_discounting) if max_iter is None: ...
[ "def", "value_iteration", "(", "self", ",", "v_init", "=", "None", ",", "epsilon", "=", "None", ",", "max_iter", "=", "None", ")", ":", "if", "self", ".", "beta", "==", "1", ":", "raise", "NotImplementedError", "(", "self", ".", "_error_msg_no_discounting"...
Solve the optimization problem by value iteration. See the `solve` method.
[ "Solve", "the", "optimization", "problem", "by", "value", "iteration", ".", "See", "the", "solve", "method", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/markov/ddp.py#L754-L795
train
Solve the optimization problem by value iteration.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/markov/ddp.py
DiscreteDP.policy_iteration
def policy_iteration(self, v_init=None, max_iter=None): """ Solve the optimization problem by policy iteration. See the `solve` method. """ if self.beta == 1: raise NotImplementedError(self._error_msg_no_discounting) if max_iter is None: max_iter...
python
def policy_iteration(self, v_init=None, max_iter=None): """ Solve the optimization problem by policy iteration. See the `solve` method. """ if self.beta == 1: raise NotImplementedError(self._error_msg_no_discounting) if max_iter is None: max_iter...
[ "def", "policy_iteration", "(", "self", ",", "v_init", "=", "None", ",", "max_iter", "=", "None", ")", ":", "if", "self", ".", "beta", "==", "1", ":", "raise", "NotImplementedError", "(", "self", ".", "_error_msg_no_discounting", ")", "if", "max_iter", "is...
Solve the optimization problem by policy iteration. See the `solve` method.
[ "Solve", "the", "optimization", "problem", "by", "policy", "iteration", ".", "See", "the", "solve", "method", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/markov/ddp.py#L797-L834
train
Solve the optimization problem by policy iteration.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/markov/ddp.py
DiscreteDP.modified_policy_iteration
def modified_policy_iteration(self, v_init=None, epsilon=None, max_iter=None, k=20): """ Solve the optimization problem by modified policy iteration. See the `solve` method. """ if self.beta == 1: raise NotImplementedError(self._erro...
python
def modified_policy_iteration(self, v_init=None, epsilon=None, max_iter=None, k=20): """ Solve the optimization problem by modified policy iteration. See the `solve` method. """ if self.beta == 1: raise NotImplementedError(self._erro...
[ "def", "modified_policy_iteration", "(", "self", ",", "v_init", "=", "None", ",", "epsilon", "=", "None", ",", "max_iter", "=", "None", ",", "k", "=", "20", ")", ":", "if", "self", ".", "beta", "==", "1", ":", "raise", "NotImplementedError", "(", "self...
Solve the optimization problem by modified policy iteration. See the `solve` method.
[ "Solve", "the", "optimization", "problem", "by", "modified", "policy", "iteration", ".", "See", "the", "solve", "method", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/markov/ddp.py#L836-L893
train
Solve the optimization problem by modified policy iteration.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/markov/ddp.py
DiscreteDP.controlled_mc
def controlled_mc(self, sigma): """ Returns the controlled Markov chain for a given policy `sigma`. Parameters ---------- sigma : array_like(int, ndim=1) Policy vector, of length n. Returns ------- mc : MarkovChain Controlled Mark...
python
def controlled_mc(self, sigma): """ Returns the controlled Markov chain for a given policy `sigma`. Parameters ---------- sigma : array_like(int, ndim=1) Policy vector, of length n. Returns ------- mc : MarkovChain Controlled Mark...
[ "def", "controlled_mc", "(", "self", ",", "sigma", ")", ":", "_", ",", "Q_sigma", "=", "self", ".", "RQ_sigma", "(", "sigma", ")", "return", "MarkovChain", "(", "Q_sigma", ")" ]
Returns the controlled Markov chain for a given policy `sigma`. Parameters ---------- sigma : array_like(int, ndim=1) Policy vector, of length n. Returns ------- mc : MarkovChain Controlled Markov chain.
[ "Returns", "the", "controlled", "Markov", "chain", "for", "a", "given", "policy", "sigma", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/markov/ddp.py#L895-L911
train
Returns the controlled Markov chain for a given policy vector sigma.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/estspec.py
smooth
def smooth(x, window_len=7, window='hanning'): """ Smooth the data in x using convolution with a window of requested size and type. Parameters ---------- x : array_like(float) A flat NumPy array containing the data to smooth window_len : scalar(int), optional An odd integer ...
python
def smooth(x, window_len=7, window='hanning'): """ Smooth the data in x using convolution with a window of requested size and type. Parameters ---------- x : array_like(float) A flat NumPy array containing the data to smooth window_len : scalar(int), optional An odd integer ...
[ "def", "smooth", "(", "x", ",", "window_len", "=", "7", ",", "window", "=", "'hanning'", ")", ":", "if", "len", "(", "x", ")", "<", "window_len", ":", "raise", "ValueError", "(", "\"Input vector length must be >= window length.\"", ")", "if", "window_len", "...
Smooth the data in x using convolution with a window of requested size and type. Parameters ---------- x : array_like(float) A flat NumPy array containing the data to smooth window_len : scalar(int), optional An odd integer giving the length of the window. Defaults to 7. window...
[ "Smooth", "the", "data", "in", "x", "using", "convolution", "with", "a", "window", "of", "requested", "size", "and", "type", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/estspec.py#L9-L67
train
Smooth the data in x using convolution with a window of requested size and type.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/estspec.py
periodogram
def periodogram(x, window=None, window_len=7): r""" Computes the periodogram .. math:: I(w) = \frac{1}{n} \Big[ \sum_{t=0}^{n-1} x_t e^{itw} \Big] ^2 at the Fourier frequences :math:`w_j := \frac{2 \pi j}{n}`, :math:`j = 0, \dots, n - 1`, using the fast Fourier transform. Only the fre...
python
def periodogram(x, window=None, window_len=7): r""" Computes the periodogram .. math:: I(w) = \frac{1}{n} \Big[ \sum_{t=0}^{n-1} x_t e^{itw} \Big] ^2 at the Fourier frequences :math:`w_j := \frac{2 \pi j}{n}`, :math:`j = 0, \dots, n - 1`, using the fast Fourier transform. Only the fre...
[ "def", "periodogram", "(", "x", ",", "window", "=", "None", ",", "window_len", "=", "7", ")", ":", "n", "=", "len", "(", "x", ")", "I_w", "=", "np", ".", "abs", "(", "fft", "(", "x", ")", ")", "**", "2", "/", "n", "w", "=", "2", "*", "np"...
r""" Computes the periodogram .. math:: I(w) = \frac{1}{n} \Big[ \sum_{t=0}^{n-1} x_t e^{itw} \Big] ^2 at the Fourier frequences :math:`w_j := \frac{2 \pi j}{n}`, :math:`j = 0, \dots, n - 1`, using the fast Fourier transform. Only the frequences :math:`w_j` in :math:`[0, \pi]` and corresp...
[ "r", "Computes", "the", "periodogram" ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/estspec.py#L70-L108
train
r Computes the periodogram at the Fourier frequences at which the periodogram is evaluated.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/estspec.py
ar_periodogram
def ar_periodogram(x, window='hanning', window_len=7): """ Compute periodogram from data x, using prewhitening, smoothing and recoloring. The data is fitted to an AR(1) model for prewhitening, and the residuals are used to compute a first-pass periodogram with smoothing. The fitted coefficients ar...
python
def ar_periodogram(x, window='hanning', window_len=7): """ Compute periodogram from data x, using prewhitening, smoothing and recoloring. The data is fitted to an AR(1) model for prewhitening, and the residuals are used to compute a first-pass periodogram with smoothing. The fitted coefficients ar...
[ "def", "ar_periodogram", "(", "x", ",", "window", "=", "'hanning'", ",", "window_len", "=", "7", ")", ":", "# === run regression === #", "x_lag", "=", "x", "[", ":", "-", "1", "]", "# lagged x", "X", "=", "np", ".", "array", "(", "[", "np", ".", "one...
Compute periodogram from data x, using prewhitening, smoothing and recoloring. The data is fitted to an AR(1) model for prewhitening, and the residuals are used to compute a first-pass periodogram with smoothing. The fitted coefficients are then used for recoloring. Parameters ---------- x : ...
[ "Compute", "periodogram", "from", "data", "x", "using", "prewhitening", "smoothing", "and", "recoloring", ".", "The", "data", "is", "fitted", "to", "an", "AR", "(", "1", ")", "model", "for", "prewhitening", "and", "the", "residuals", "are", "used", "to", "...
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/estspec.py#L111-L152
train
Compute periodograms at the current Fourier frequences at which periodogram is evaluated.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/game_theory/support_enumeration.py
support_enumeration_gen
def support_enumeration_gen(g): """ Generator version of `support_enumeration`. Parameters ---------- g : NormalFormGame NormalFormGame instance with 2 players. Yields ------- tuple(ndarray(float, ndim=1)) Tuple of Nash equilibrium mixed actions. """ try: ...
python
def support_enumeration_gen(g): """ Generator version of `support_enumeration`. Parameters ---------- g : NormalFormGame NormalFormGame instance with 2 players. Yields ------- tuple(ndarray(float, ndim=1)) Tuple of Nash equilibrium mixed actions. """ try: ...
[ "def", "support_enumeration_gen", "(", "g", ")", ":", "try", ":", "N", "=", "g", ".", "N", "except", ":", "raise", "TypeError", "(", "'input must be a 2-player NormalFormGame'", ")", "if", "N", "!=", "2", ":", "raise", "NotImplementedError", "(", "'Implemented...
Generator version of `support_enumeration`. Parameters ---------- g : NormalFormGame NormalFormGame instance with 2 players. Yields ------- tuple(ndarray(float, ndim=1)) Tuple of Nash equilibrium mixed actions.
[ "Generator", "version", "of", "support_enumeration", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/game_theory/support_enumeration.py#L42-L63
train
Generator version of support_enumeration.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/game_theory/support_enumeration.py
_support_enumeration_gen
def _support_enumeration_gen(payoff_matrices): """ Main body of `support_enumeration_gen`. Parameters ---------- payoff_matrices : tuple(ndarray(float, ndim=2)) Tuple of payoff matrices, of shapes (m, n) and (n, m), respectively. Yields ------ out : tuple(ndarray(float,...
python
def _support_enumeration_gen(payoff_matrices): """ Main body of `support_enumeration_gen`. Parameters ---------- payoff_matrices : tuple(ndarray(float, ndim=2)) Tuple of payoff matrices, of shapes (m, n) and (n, m), respectively. Yields ------ out : tuple(ndarray(float,...
[ "def", "_support_enumeration_gen", "(", "payoff_matrices", ")", ":", "nums_actions", "=", "payoff_matrices", "[", "0", "]", ".", "shape", "n_min", "=", "min", "(", "nums_actions", ")", "for", "k", "in", "range", "(", "1", ",", "n_min", "+", "1", ")", ":"...
Main body of `support_enumeration_gen`. Parameters ---------- payoff_matrices : tuple(ndarray(float, ndim=2)) Tuple of payoff matrices, of shapes (m, n) and (n, m), respectively. Yields ------ out : tuple(ndarray(float, ndim=1)) Tuple of Nash equilibrium mixed actions, ...
[ "Main", "body", "of", "support_enumeration_gen", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/game_theory/support_enumeration.py#L67-L108
train
Generate the support_enumeration_gen.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/game_theory/support_enumeration.py
_indiff_mixed_action
def _indiff_mixed_action(payoff_matrix, own_supp, opp_supp, A, out): """ Given a player's payoff matrix `payoff_matrix`, an array `own_supp` of this player's actions, and an array `opp_supp` of the opponent's actions, each of length k, compute the opponent's mixed action whose support equals `opp_su...
python
def _indiff_mixed_action(payoff_matrix, own_supp, opp_supp, A, out): """ Given a player's payoff matrix `payoff_matrix`, an array `own_supp` of this player's actions, and an array `opp_supp` of the opponent's actions, each of length k, compute the opponent's mixed action whose support equals `opp_su...
[ "def", "_indiff_mixed_action", "(", "payoff_matrix", ",", "own_supp", ",", "opp_supp", ",", "A", ",", "out", ")", ":", "m", "=", "payoff_matrix", ".", "shape", "[", "0", "]", "k", "=", "len", "(", "own_supp", ")", "for", "i", "in", "range", "(", "k",...
Given a player's payoff matrix `payoff_matrix`, an array `own_supp` of this player's actions, and an array `opp_supp` of the opponent's actions, each of length k, compute the opponent's mixed action whose support equals `opp_supp` and for which the player is indifferent among the actions in `own_supp`, ...
[ "Given", "a", "player", "s", "payoff", "matrix", "payoff_matrix", "an", "array", "own_supp", "of", "this", "player", "s", "actions", "and", "an", "array", "opp_supp", "of", "the", "opponent", "s", "actions", "each", "of", "length", "k", "compute", "the", "...
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/game_theory/support_enumeration.py#L112-L180
train
Compute the indifferent mixed action for a player.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/game_theory/normal_form_game.py
pure2mixed
def pure2mixed(num_actions, action): """ Convert a pure action to the corresponding mixed action. Parameters ---------- num_actions : scalar(int) The number of the pure actions (= the length of a mixed action). action : scalar(int) The pure action to convert to the correspondin...
python
def pure2mixed(num_actions, action): """ Convert a pure action to the corresponding mixed action. Parameters ---------- num_actions : scalar(int) The number of the pure actions (= the length of a mixed action). action : scalar(int) The pure action to convert to the correspondin...
[ "def", "pure2mixed", "(", "num_actions", ",", "action", ")", ":", "mixed_action", "=", "np", ".", "zeros", "(", "num_actions", ")", "mixed_action", "[", "action", "]", "=", "1", "return", "mixed_action" ]
Convert a pure action to the corresponding mixed action. Parameters ---------- num_actions : scalar(int) The number of the pure actions (= the length of a mixed action). action : scalar(int) The pure action to convert to the corresponding mixed action. Returns ------- ndar...
[ "Convert", "a", "pure", "action", "to", "the", "corresponding", "mixed", "action", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/game_theory/normal_form_game.py#L864-L884
train
Convert a pure action to the corresponding mixed action.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/game_theory/normal_form_game.py
best_response_2p
def best_response_2p(payoff_matrix, opponent_mixed_action, tol=1e-8): """ Numba-optimized version of `Player.best_response` compilied in nopython mode, specialized for 2-player games (where there is only one opponent). Return the best response action (with the smallest index if more than one) t...
python
def best_response_2p(payoff_matrix, opponent_mixed_action, tol=1e-8): """ Numba-optimized version of `Player.best_response` compilied in nopython mode, specialized for 2-player games (where there is only one opponent). Return the best response action (with the smallest index if more than one) t...
[ "def", "best_response_2p", "(", "payoff_matrix", ",", "opponent_mixed_action", ",", "tol", "=", "1e-8", ")", ":", "n", ",", "m", "=", "payoff_matrix", ".", "shape", "payoff_max", "=", "-", "np", ".", "inf", "payoff_vector", "=", "np", ".", "zeros", "(", ...
Numba-optimized version of `Player.best_response` compilied in nopython mode, specialized for 2-player games (where there is only one opponent). Return the best response action (with the smallest index if more than one) to `opponent_mixed_action` under `payoff_matrix`. Parameters ---------- ...
[ "Numba", "-", "optimized", "version", "of", "Player", ".", "best_response", "compilied", "in", "nopython", "mode", "specialized", "for", "2", "-", "player", "games", "(", "where", "there", "is", "only", "one", "opponent", ")", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/game_theory/normal_form_game.py#L890-L930
train
This function is used to compute the best response action for a single player in a numba - optimized mode.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/game_theory/normal_form_game.py
Player.delete_action
def delete_action(self, action, player_idx=0): """ Return a new `Player` instance with the action(s) specified by `action` deleted from the action set of the player specified by `player_idx`. Deletion is not performed in place. Parameters ---------- action : scal...
python
def delete_action(self, action, player_idx=0): """ Return a new `Player` instance with the action(s) specified by `action` deleted from the action set of the player specified by `player_idx`. Deletion is not performed in place. Parameters ---------- action : scal...
[ "def", "delete_action", "(", "self", ",", "action", ",", "player_idx", "=", "0", ")", ":", "payoff_array_new", "=", "np", ".", "delete", "(", "self", ".", "payoff_array", ",", "action", ",", "player_idx", ")", "return", "Player", "(", "payoff_array_new", "...
Return a new `Player` instance with the action(s) specified by `action` deleted from the action set of the player specified by `player_idx`. Deletion is not performed in place. Parameters ---------- action : scalar(int) or array_like(int) Integer or array like of int...
[ "Return", "a", "new", "Player", "instance", "with", "the", "action", "(", "s", ")", "specified", "by", "action", "deleted", "from", "the", "action", "set", "of", "the", "player", "specified", "by", "player_idx", ".", "Deletion", "is", "not", "performed", "...
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/game_theory/normal_form_game.py#L197-L234
train
Delete the action set of a specific player.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/game_theory/normal_form_game.py
Player.payoff_vector
def payoff_vector(self, opponents_actions): """ Return an array of payoff values, one for each own action, given a profile of the opponents' actions. Parameters ---------- opponents_actions : see `best_response`. Returns ------- payoff_vector : n...
python
def payoff_vector(self, opponents_actions): """ Return an array of payoff values, one for each own action, given a profile of the opponents' actions. Parameters ---------- opponents_actions : see `best_response`. Returns ------- payoff_vector : n...
[ "def", "payoff_vector", "(", "self", ",", "opponents_actions", ")", ":", "def", "reduce_last_player", "(", "payoff_array", ",", "action", ")", ":", "\"\"\"\n Given `payoff_array` with ndim=M, return the payoff array\n with ndim=M-1 fixing the last player's actio...
Return an array of payoff values, one for each own action, given a profile of the opponents' actions. Parameters ---------- opponents_actions : see `best_response`. Returns ------- payoff_vector : ndarray(float, ndim=1) An array representing the play...
[ "Return", "an", "array", "of", "payoff", "values", "one", "for", "each", "own", "action", "given", "a", "profile", "of", "the", "opponents", "actions", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/game_theory/normal_form_game.py#L236-L274
train
Returns an array of payoff values one for each own action given the profile of the opponents actions.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/game_theory/normal_form_game.py
Player.is_best_response
def is_best_response(self, own_action, opponents_actions, tol=None): """ Return True if `own_action` is a best response to `opponents_actions`. Parameters ---------- own_action : scalar(int) or array_like(float, ndim=1) An integer representing a pure action, ...
python
def is_best_response(self, own_action, opponents_actions, tol=None): """ Return True if `own_action` is a best response to `opponents_actions`. Parameters ---------- own_action : scalar(int) or array_like(float, ndim=1) An integer representing a pure action, ...
[ "def", "is_best_response", "(", "self", ",", "own_action", ",", "opponents_actions", ",", "tol", "=", "None", ")", ":", "if", "tol", "is", "None", ":", "tol", "=", "self", ".", "tol", "payoff_vector", "=", "self", ".", "payoff_vector", "(", "opponents_acti...
Return True if `own_action` is a best response to `opponents_actions`. Parameters ---------- own_action : scalar(int) or array_like(float, ndim=1) An integer representing a pure action, or an array of floats representing a mixed action. opponents_actions...
[ "Return", "True", "if", "own_action", "is", "a", "best", "response", "to", "opponents_actions", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/game_theory/normal_form_game.py#L276-L309
train
Return True if own_action is a best response to opponents_actions.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/game_theory/normal_form_game.py
Player.best_response
def best_response(self, opponents_actions, tie_breaking='smallest', payoff_perturbation=None, tol=None, random_state=None): """ Return the best response action(s) to `opponents_actions`. Parameters ---------- opponents_actions : scalar(int) or array_like ...
python
def best_response(self, opponents_actions, tie_breaking='smallest', payoff_perturbation=None, tol=None, random_state=None): """ Return the best response action(s) to `opponents_actions`. Parameters ---------- opponents_actions : scalar(int) or array_like ...
[ "def", "best_response", "(", "self", ",", "opponents_actions", ",", "tie_breaking", "=", "'smallest'", ",", "payoff_perturbation", "=", "None", ",", "tol", "=", "None", ",", "random_state", "=", "None", ")", ":", "if", "tol", "is", "None", ":", "tol", "=",...
Return the best response action(s) to `opponents_actions`. Parameters ---------- opponents_actions : scalar(int) or array_like A profile of N-1 opponents' actions, represented by either scalar(int), array_like(float), array_like(int), or array_like(array_like...
[ "Return", "the", "best", "response", "action", "(", "s", ")", "to", "opponents_actions", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/game_theory/normal_form_game.py#L311-L380
train
Return the best response action to opponents_actions.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/game_theory/normal_form_game.py
Player.random_choice
def random_choice(self, actions=None, random_state=None): """ Return a pure action chosen randomly from `actions`. Parameters ---------- actions : array_like(int), optional(default=None) An array of integers representing pure actions. random_state : int or n...
python
def random_choice(self, actions=None, random_state=None): """ Return a pure action chosen randomly from `actions`. Parameters ---------- actions : array_like(int), optional(default=None) An array of integers representing pure actions. random_state : int or n...
[ "def", "random_choice", "(", "self", ",", "actions", "=", "None", ",", "random_state", "=", "None", ")", ":", "random_state", "=", "check_random_state", "(", "random_state", ")", "if", "actions", "is", "not", "None", ":", "n", "=", "len", "(", "actions", ...
Return a pure action chosen randomly from `actions`. Parameters ---------- actions : array_like(int), optional(default=None) An array of integers representing pure actions. random_state : int or np.random.RandomState, optional Random seed (integer) or np.random....
[ "Return", "a", "pure", "action", "chosen", "randomly", "from", "actions", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/game_theory/normal_form_game.py#L382-L420
train
Returns a random action from the actions array.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/game_theory/normal_form_game.py
Player.is_dominated
def is_dominated(self, action, tol=None, method=None): """ Determine whether `action` is strictly dominated by some mixed action. Parameters ---------- action : scalar(int) Integer representing a pure action. tol : scalar(float), optional(default=Non...
python
def is_dominated(self, action, tol=None, method=None): """ Determine whether `action` is strictly dominated by some mixed action. Parameters ---------- action : scalar(int) Integer representing a pure action. tol : scalar(float), optional(default=Non...
[ "def", "is_dominated", "(", "self", ",", "action", ",", "tol", "=", "None", ",", "method", "=", "None", ")", ":", "if", "tol", "is", "None", ":", "tol", "=", "self", ".", "tol", "payoff_array", "=", "self", ".", "payoff_array", "if", "self", ".", "...
Determine whether `action` is strictly dominated by some mixed action. Parameters ---------- action : scalar(int) Integer representing a pure action. tol : scalar(float), optional(default=None) Tolerance level used in determining domination. If None, ...
[ "Determine", "whether", "action", "is", "strictly", "dominated", "by", "some", "mixed", "action", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/game_theory/normal_form_game.py#L422-L494
train
Determines if an action is strictly dominated by some mixed action.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/game_theory/normal_form_game.py
Player.dominated_actions
def dominated_actions(self, tol=None, method=None): """ Return a list of actions that are strictly dominated by some mixed actions. Parameters ---------- tol : scalar(float), optional(default=None) Tolerance level used in determining domination. If None, ...
python
def dominated_actions(self, tol=None, method=None): """ Return a list of actions that are strictly dominated by some mixed actions. Parameters ---------- tol : scalar(float), optional(default=None) Tolerance level used in determining domination. If None, ...
[ "def", "dominated_actions", "(", "self", ",", "tol", "=", "None", ",", "method", "=", "None", ")", ":", "out", "=", "[", "]", "for", "action", "in", "range", "(", "self", ".", "num_actions", ")", ":", "if", "self", ".", "is_dominated", "(", "action",...
Return a list of actions that are strictly dominated by some mixed actions. Parameters ---------- tol : scalar(float), optional(default=None) Tolerance level used in determining domination. If None, default to the value of the `tol` attribute. method : s...
[ "Return", "a", "list", "of", "actions", "that", "are", "strictly", "dominated", "by", "some", "mixed", "actions", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/game_theory/normal_form_game.py#L496-L525
train
Returns a list of actions that are strictly dominated by some mixed action.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/game_theory/normal_form_game.py
NormalFormGame.delete_action
def delete_action(self, player_idx, action): """ Return a new `NormalFormGame` instance with the action(s) specified by `action` deleted from the action set of the player specified by `player_idx`. Deletion is not performed in place. Parameters ---------- player_...
python
def delete_action(self, player_idx, action): """ Return a new `NormalFormGame` instance with the action(s) specified by `action` deleted from the action set of the player specified by `player_idx`. Deletion is not performed in place. Parameters ---------- player_...
[ "def", "delete_action", "(", "self", ",", "player_idx", ",", "action", ")", ":", "# Allow negative indexing", "if", "-", "self", ".", "N", "<=", "player_idx", "<", "0", ":", "player_idx", "=", "player_idx", "+", "self", ".", "N", "players_new", "=", "tuple...
Return a new `NormalFormGame` instance with the action(s) specified by `action` deleted from the action set of the player specified by `player_idx`. Deletion is not performed in place. Parameters ---------- player_idx : scalar(int) Index of the player to delete actio...
[ "Return", "a", "new", "NormalFormGame", "instance", "with", "the", "action", "(", "s", ")", "specified", "by", "action", "deleted", "from", "the", "action", "set", "of", "the", "player", "specified", "by", "player_idx", ".", "Deletion", "is", "not", "perform...
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/game_theory/normal_form_game.py#L730-L786
train
Delete the action set of the player with the specified index.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/game_theory/normal_form_game.py
NormalFormGame.is_nash
def is_nash(self, action_profile, tol=None): """ Return True if `action_profile` is a Nash equilibrium. Parameters ---------- action_profile : array_like(int or array_like(float)) An array of N objects, where each object must be an integer (pure action) o...
python
def is_nash(self, action_profile, tol=None): """ Return True if `action_profile` is a Nash equilibrium. Parameters ---------- action_profile : array_like(int or array_like(float)) An array of N objects, where each object must be an integer (pure action) o...
[ "def", "is_nash", "(", "self", ",", "action_profile", ",", "tol", "=", "None", ")", ":", "if", "self", ".", "N", "==", "2", ":", "for", "i", ",", "player", "in", "enumerate", "(", "self", ".", "players", ")", ":", "own_action", ",", "opponent_action"...
Return True if `action_profile` is a Nash equilibrium. Parameters ---------- action_profile : array_like(int or array_like(float)) An array of N objects, where each object must be an integer (pure action) or an array of floats (mixed action). tol : scalar(float)...
[ "Return", "True", "if", "action_profile", "is", "a", "Nash", "equilibrium", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/game_theory/normal_form_game.py#L788-L832
train
Return True if the action_profile is a Nash equilibrium.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/game_theory/mclennan_tourky.py
mclennan_tourky
def mclennan_tourky(g, init=None, epsilon=1e-3, max_iter=200, full_output=False): r""" Find one mixed-action epsilon-Nash equilibrium of an N-player normal form game by the fixed point computation algorithm by McLennan and Tourky [1]_. Parameters ---------- g : NormalFor...
python
def mclennan_tourky(g, init=None, epsilon=1e-3, max_iter=200, full_output=False): r""" Find one mixed-action epsilon-Nash equilibrium of an N-player normal form game by the fixed point computation algorithm by McLennan and Tourky [1]_. Parameters ---------- g : NormalFor...
[ "def", "mclennan_tourky", "(", "g", ",", "init", "=", "None", ",", "epsilon", "=", "1e-3", ",", "max_iter", "=", "200", ",", "full_output", "=", "False", ")", ":", "try", ":", "N", "=", "g", ".", "N", "except", ":", "raise", "TypeError", "(", "'g m...
r""" Find one mixed-action epsilon-Nash equilibrium of an N-player normal form game by the fixed point computation algorithm by McLennan and Tourky [1]_. Parameters ---------- g : NormalFormGame NormalFormGame instance. init : array_like(int or array_like(float, ndim=1)), optional ...
[ "r", "Find", "one", "mixed", "-", "action", "epsilon", "-", "Nash", "equilibrium", "of", "an", "N", "-", "player", "normal", "form", "game", "by", "the", "fixed", "point", "computation", "algorithm", "by", "McLennan", "and", "Tourky", "[", "1", "]", "_",...
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/game_theory/mclennan_tourky.py#L14-L148
train
r This function is used to compute mixed - action epsilon - Nash equilibriums of a normal - form game by McLennan and McTourky.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/game_theory/mclennan_tourky.py
_best_response_selection
def _best_response_selection(x, g, indptr=None): """ Selection of the best response correspondence of `g` that selects the best response action with the smallest index when there are ties, where the input and output are flattened action profiles. Parameters ---------- x : array_like(float, ...
python
def _best_response_selection(x, g, indptr=None): """ Selection of the best response correspondence of `g` that selects the best response action with the smallest index when there are ties, where the input and output are flattened action profiles. Parameters ---------- x : array_like(float, ...
[ "def", "_best_response_selection", "(", "x", ",", "g", ",", "indptr", "=", "None", ")", ":", "N", "=", "g", ".", "N", "if", "indptr", "is", "None", ":", "indptr", "=", "np", ".", "empty", "(", "N", "+", "1", ",", "dtype", "=", "int", ")", "indp...
Selection of the best response correspondence of `g` that selects the best response action with the smallest index when there are ties, where the input and output are flattened action profiles. Parameters ---------- x : array_like(float, ndim=1) Array of flattened mixed action profile of le...
[ "Selection", "of", "the", "best", "response", "correspondence", "of", "g", "that", "selects", "the", "best", "response", "action", "with", "the", "smallest", "index", "when", "there", "are", "ties", "where", "the", "input", "and", "output", "are", "flattened",...
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/game_theory/mclennan_tourky.py#L151-L200
train
This function returns the selection of the best response correspondence of g that selects the best response action with the smallest index when there are no ties.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/game_theory/mclennan_tourky.py
_is_epsilon_nash
def _is_epsilon_nash(x, g, epsilon, indptr=None): """ Determine whether `x` is an `epsilon`-Nash equilibrium of `g`. Parameters ---------- x : array_like(float, ndim=1) Array of flattened mixed action profile of length equal to n_0 + ... + n_N-1, where `out[indptr[i]:indptr[i+1]]` c...
python
def _is_epsilon_nash(x, g, epsilon, indptr=None): """ Determine whether `x` is an `epsilon`-Nash equilibrium of `g`. Parameters ---------- x : array_like(float, ndim=1) Array of flattened mixed action profile of length equal to n_0 + ... + n_N-1, where `out[indptr[i]:indptr[i+1]]` c...
[ "def", "_is_epsilon_nash", "(", "x", ",", "g", ",", "epsilon", ",", "indptr", "=", "None", ")", ":", "if", "indptr", "is", "None", ":", "indptr", "=", "np", ".", "empty", "(", "g", ".", "N", "+", "1", ",", "dtype", "=", "int", ")", "indptr", "[...
Determine whether `x` is an `epsilon`-Nash equilibrium of `g`. Parameters ---------- x : array_like(float, ndim=1) Array of flattened mixed action profile of length equal to n_0 + ... + n_N-1, where `out[indptr[i]:indptr[i+1]]` contains player i's mixed action. g : NormalFormGa...
[ "Determine", "whether", "x", "is", "an", "epsilon", "-", "Nash", "equilibrium", "of", "g", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/game_theory/mclennan_tourky.py#L203-L233
train
Determines whether x is an epsilon - Nash equilibrium of g.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/game_theory/mclennan_tourky.py
_get_action_profile
def _get_action_profile(x, indptr): """ Obtain a tuple of mixed actions from a flattened action profile. Parameters ---------- x : array_like(float, ndim=1) Array of flattened mixed action profile of length equal to n_0 + ... + n_N-1, where `out[indptr[i]:indptr[i+1]]` contains play...
python
def _get_action_profile(x, indptr): """ Obtain a tuple of mixed actions from a flattened action profile. Parameters ---------- x : array_like(float, ndim=1) Array of flattened mixed action profile of length equal to n_0 + ... + n_N-1, where `out[indptr[i]:indptr[i+1]]` contains play...
[ "def", "_get_action_profile", "(", "x", ",", "indptr", ")", ":", "N", "=", "len", "(", "indptr", ")", "-", "1", "action_profile", "=", "tuple", "(", "x", "[", "indptr", "[", "i", "]", ":", "indptr", "[", "i", "+", "1", "]", "]", "for", "i", "in...
Obtain a tuple of mixed actions from a flattened action profile. Parameters ---------- x : array_like(float, ndim=1) Array of flattened mixed action profile of length equal to n_0 + ... + n_N-1, where `out[indptr[i]:indptr[i+1]]` contains player i's mixed action. indptr : array...
[ "Obtain", "a", "tuple", "of", "mixed", "actions", "from", "a", "flattened", "action", "profile", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/game_theory/mclennan_tourky.py#L236-L259
train
Returns a tuple of mixed actions from a flattened action profile.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/game_theory/mclennan_tourky.py
_flatten_action_profile
def _flatten_action_profile(action_profile, indptr): """ Flatten the given action profile. Parameters ---------- action_profile : array_like(int or array_like(float, ndim=1)) Profile of actions of the N players, where each player i' action is a pure action (int) or a mixed action (a...
python
def _flatten_action_profile(action_profile, indptr): """ Flatten the given action profile. Parameters ---------- action_profile : array_like(int or array_like(float, ndim=1)) Profile of actions of the N players, where each player i' action is a pure action (int) or a mixed action (a...
[ "def", "_flatten_action_profile", "(", "action_profile", ",", "indptr", ")", ":", "N", "=", "len", "(", "indptr", ")", "-", "1", "out", "=", "np", ".", "empty", "(", "indptr", "[", "-", "1", "]", ")", "for", "i", "in", "range", "(", "N", ")", ":"...
Flatten the given action profile. Parameters ---------- action_profile : array_like(int or array_like(float, ndim=1)) Profile of actions of the N players, where each player i' action is a pure action (int) or a mixed action (array_like of floats of length n_i). indptr : array_l...
[ "Flatten", "the", "given", "action", "profile", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/game_theory/mclennan_tourky.py#L262-L296
train
Flatten the given action profile into a single array of mixed actions.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/game_theory/game_generators/bimatrix_generators.py
blotto_game
def blotto_game(h, t, rho, mu=0, random_state=None): """ Return a NormalFormGame instance of a 2-player non-zero sum Colonel Blotto game (Hortala-Vallve and Llorente-Saguer, 2012), where the players have an equal number `t` of troops to assign to `h` hills (so that the number of actions for each pla...
python
def blotto_game(h, t, rho, mu=0, random_state=None): """ Return a NormalFormGame instance of a 2-player non-zero sum Colonel Blotto game (Hortala-Vallve and Llorente-Saguer, 2012), where the players have an equal number `t` of troops to assign to `h` hills (so that the number of actions for each pla...
[ "def", "blotto_game", "(", "h", ",", "t", ",", "rho", ",", "mu", "=", "0", ",", "random_state", "=", "None", ")", ":", "actions", "=", "simplex_grid", "(", "h", ",", "t", ")", "n", "=", "actions", ".", "shape", "[", "0", "]", "payoff_arrays", "="...
Return a NormalFormGame instance of a 2-player non-zero sum Colonel Blotto game (Hortala-Vallve and Llorente-Saguer, 2012), where the players have an equal number `t` of troops to assign to `h` hills (so that the number of actions for each player is equal to (t+h-1) choose (h-1) = (t+h-1)!/(t!*(h-1)!))....
[ "Return", "a", "NormalFormGame", "instance", "of", "a", "2", "-", "player", "non", "-", "zero", "sum", "Colonel", "Blotto", "game", "(", "Hortala", "-", "Vallve", "and", "Llorente", "-", "Saguer", "2012", ")", "where", "the", "players", "have", "an", "eq...
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/game_theory/game_generators/bimatrix_generators.py#L103-L163
train
Returns a NormalFormGame instance of a 2 - player non - zero sum Colonel
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/game_theory/game_generators/bimatrix_generators.py
_populate_blotto_payoff_arrays
def _populate_blotto_payoff_arrays(payoff_arrays, actions, values): """ Populate the ndarrays in `payoff_arrays` with the payoff values of the Blotto game with h hills and t troops. Parameters ---------- payoff_arrays : tuple(ndarray(float, ndim=2)) Tuple of 2 ndarrays of shape (n, n), ...
python
def _populate_blotto_payoff_arrays(payoff_arrays, actions, values): """ Populate the ndarrays in `payoff_arrays` with the payoff values of the Blotto game with h hills and t troops. Parameters ---------- payoff_arrays : tuple(ndarray(float, ndim=2)) Tuple of 2 ndarrays of shape (n, n), ...
[ "def", "_populate_blotto_payoff_arrays", "(", "payoff_arrays", ",", "actions", ",", "values", ")", ":", "n", ",", "h", "=", "actions", ".", "shape", "payoffs", "=", "np", ".", "empty", "(", "2", ")", "for", "i", "in", "range", "(", "n", ")", ":", "fo...
Populate the ndarrays in `payoff_arrays` with the payoff values of the Blotto game with h hills and t troops. Parameters ---------- payoff_arrays : tuple(ndarray(float, ndim=2)) Tuple of 2 ndarrays of shape (n, n), where n = (t+h-1)!/ (t!*(h-1)!). Modified in place. actions : ndarra...
[ "Populate", "the", "ndarrays", "in", "payoff_arrays", "with", "the", "payoff", "values", "of", "the", "Blotto", "game", "with", "h", "hills", "and", "t", "troops", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/game_theory/game_generators/bimatrix_generators.py#L167-L197
train
Populate the ndarrays in the payoff_arrays with the payoff values of the current node.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/game_theory/game_generators/bimatrix_generators.py
ranking_game
def ranking_game(n, steps=10, random_state=None): """ Return a NormalFormGame instance of (the 2-player version of) the "ranking game" studied by Goldberg et al. (2013), where each player chooses an effort level associated with a score and a cost which are both increasing functions with randomly gen...
python
def ranking_game(n, steps=10, random_state=None): """ Return a NormalFormGame instance of (the 2-player version of) the "ranking game" studied by Goldberg et al. (2013), where each player chooses an effort level associated with a score and a cost which are both increasing functions with randomly gen...
[ "def", "ranking_game", "(", "n", ",", "steps", "=", "10", ",", "random_state", "=", "None", ")", ":", "payoff_arrays", "=", "tuple", "(", "np", ".", "empty", "(", "(", "n", ",", "n", ")", ")", "for", "i", "in", "range", "(", "2", ")", ")", "ran...
Return a NormalFormGame instance of (the 2-player version of) the "ranking game" studied by Goldberg et al. (2013), where each player chooses an effort level associated with a score and a cost which are both increasing functions with randomly generated step sizes. The player with the higher score wins t...
[ "Return", "a", "NormalFormGame", "instance", "of", "(", "the", "2", "-", "player", "version", "of", ")", "the", "ranking", "game", "studied", "by", "Goldberg", "et", "al", ".", "(", "2013", ")", "where", "each", "player", "chooses", "an", "effort", "leve...
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/game_theory/game_generators/bimatrix_generators.py#L200-L265
train
Returns a ranking game for the given number of steps and random number generator.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/game_theory/game_generators/bimatrix_generators.py
_populate_ranking_payoff_arrays
def _populate_ranking_payoff_arrays(payoff_arrays, scores, costs): """ Populate the ndarrays in `payoff_arrays` with the payoff values of the ranking game given `scores` and `costs`. Parameters ---------- payoff_arrays : tuple(ndarray(float, ndim=2)) Tuple of 2 ndarrays of shape (n, n)....
python
def _populate_ranking_payoff_arrays(payoff_arrays, scores, costs): """ Populate the ndarrays in `payoff_arrays` with the payoff values of the ranking game given `scores` and `costs`. Parameters ---------- payoff_arrays : tuple(ndarray(float, ndim=2)) Tuple of 2 ndarrays of shape (n, n)....
[ "def", "_populate_ranking_payoff_arrays", "(", "payoff_arrays", ",", "scores", ",", "costs", ")", ":", "n", "=", "payoff_arrays", "[", "0", "]", ".", "shape", "[", "0", "]", "for", "p", ",", "payoff_array", "in", "enumerate", "(", "payoff_arrays", ")", ":"...
Populate the ndarrays in `payoff_arrays` with the payoff values of the ranking game given `scores` and `costs`. Parameters ---------- payoff_arrays : tuple(ndarray(float, ndim=2)) Tuple of 2 ndarrays of shape (n, n). Modified in place. scores : ndarray(int, ndim=2) ndarray of shape ...
[ "Populate", "the", "ndarrays", "in", "payoff_arrays", "with", "the", "payoff", "values", "of", "the", "ranking", "game", "given", "scores", "and", "costs", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/game_theory/game_generators/bimatrix_generators.py#L269-L303
train
Populate the ndarrays in the ranking_payoff_arrays with the payoff values of Apps that are given by the scores and costs.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/game_theory/game_generators/bimatrix_generators.py
sgc_game
def sgc_game(k): """ Return a NormalFormGame instance of the 2-player game introduced by Sandholm, Gilpin, and Conitzer (2005), which has a unique Nash equilibrium, where each player plays half of the actions with positive probabilities. Payoffs are normalized so that the minimum and the maximum...
python
def sgc_game(k): """ Return a NormalFormGame instance of the 2-player game introduced by Sandholm, Gilpin, and Conitzer (2005), which has a unique Nash equilibrium, where each player plays half of the actions with positive probabilities. Payoffs are normalized so that the minimum and the maximum...
[ "def", "sgc_game", "(", "k", ")", ":", "payoff_arrays", "=", "tuple", "(", "np", ".", "empty", "(", "(", "4", "*", "k", "-", "1", ",", "4", "*", "k", "-", "1", ")", ")", "for", "i", "in", "range", "(", "2", ")", ")", "_populate_sgc_payoff_array...
Return a NormalFormGame instance of the 2-player game introduced by Sandholm, Gilpin, and Conitzer (2005), which has a unique Nash equilibrium, where each player plays half of the actions with positive probabilities. Payoffs are normalized so that the minimum and the maximum payoffs are 0 and 1, respect...
[ "Return", "a", "NormalFormGame", "instance", "of", "the", "2", "-", "player", "game", "introduced", "by", "Sandholm", "Gilpin", "and", "Conitzer", "(", "2005", ")", "which", "has", "a", "unique", "Nash", "equilibrium", "where", "each", "player", "plays", "ha...
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/game_theory/game_generators/bimatrix_generators.py#L306-L350
train
Returns a NormalFormGame instance of the 2 - player game introduced by the given nash .
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/game_theory/game_generators/bimatrix_generators.py
_populate_sgc_payoff_arrays
def _populate_sgc_payoff_arrays(payoff_arrays): """ Populate the ndarrays in `payoff_arrays` with the payoff values of the SGC game. Parameters ---------- payoff_arrays : tuple(ndarray(float, ndim=2)) Tuple of 2 ndarrays of shape (4*k-1, 4*k-1). Modified in place. """ n = payof...
python
def _populate_sgc_payoff_arrays(payoff_arrays): """ Populate the ndarrays in `payoff_arrays` with the payoff values of the SGC game. Parameters ---------- payoff_arrays : tuple(ndarray(float, ndim=2)) Tuple of 2 ndarrays of shape (4*k-1, 4*k-1). Modified in place. """ n = payof...
[ "def", "_populate_sgc_payoff_arrays", "(", "payoff_arrays", ")", ":", "n", "=", "payoff_arrays", "[", "0", "]", ".", "shape", "[", "0", "]", "# 4*k-1", "m", "=", "(", "n", "+", "1", ")", "//", "2", "-", "1", "# 2*k-1", "for", "payoff_array", "in", "p...
Populate the ndarrays in `payoff_arrays` with the payoff values of the SGC game. Parameters ---------- payoff_arrays : tuple(ndarray(float, ndim=2)) Tuple of 2 ndarrays of shape (4*k-1, 4*k-1). Modified in place.
[ "Populate", "the", "ndarrays", "in", "payoff_arrays", "with", "the", "payoff", "values", "of", "the", "SGC", "game", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/game_theory/game_generators/bimatrix_generators.py#L354-L391
train
Populate the ndarrays in the SGC game with the payoff values of the SGC game.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/game_theory/game_generators/bimatrix_generators.py
tournament_game
def tournament_game(n, k, random_state=None): """ Return a NormalFormGame instance of the 2-player win-lose game, whose payoffs are either 0 or 1, introduced by Anbalagan et al. (2013). Player 0 has n actions, which constitute the set of nodes {0, ..., n-1}, while player 1 has n choose k actions, ea...
python
def tournament_game(n, k, random_state=None): """ Return a NormalFormGame instance of the 2-player win-lose game, whose payoffs are either 0 or 1, introduced by Anbalagan et al. (2013). Player 0 has n actions, which constitute the set of nodes {0, ..., n-1}, while player 1 has n choose k actions, ea...
[ "def", "tournament_game", "(", "n", ",", "k", ",", "random_state", "=", "None", ")", ":", "m", "=", "scipy", ".", "special", ".", "comb", "(", "n", ",", "k", ",", "exact", "=", "True", ")", "if", "m", ">", "np", ".", "iinfo", "(", "np", ".", ...
Return a NormalFormGame instance of the 2-player win-lose game, whose payoffs are either 0 or 1, introduced by Anbalagan et al. (2013). Player 0 has n actions, which constitute the set of nodes {0, ..., n-1}, while player 1 has n choose k actions, each corresponding to a subset of k elements of the set ...
[ "Return", "a", "NormalFormGame", "instance", "of", "the", "2", "-", "player", "win", "-", "lose", "game", "whose", "payoffs", "are", "either", "0", "or", "1", "introduced", "by", "Anbalagan", "et", "al", ".", "(", "2013", ")", ".", "Player", "0", "has"...
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/game_theory/game_generators/bimatrix_generators.py#L394-L469
train
Returns a NormalFormGame instance of the 2 - player win - lose game with the payoff of 0 and 1 for all of the k - subset nodes.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/game_theory/game_generators/bimatrix_generators.py
_populate_tournament_payoff_array0
def _populate_tournament_payoff_array0(payoff_array, k, indices, indptr): """ Populate `payoff_array` with the payoff values for player 0 in the tournament game given a random tournament graph in CSR format. Parameters ---------- payoff_array : ndarray(float, ndim=2) ndarray of shape (n...
python
def _populate_tournament_payoff_array0(payoff_array, k, indices, indptr): """ Populate `payoff_array` with the payoff values for player 0 in the tournament game given a random tournament graph in CSR format. Parameters ---------- payoff_array : ndarray(float, ndim=2) ndarray of shape (n...
[ "def", "_populate_tournament_payoff_array0", "(", "payoff_array", ",", "k", ",", "indices", ",", "indptr", ")", ":", "n", "=", "payoff_array", ".", "shape", "[", "0", "]", "X", "=", "np", ".", "empty", "(", "k", ",", "dtype", "=", "np", ".", "int_", ...
Populate `payoff_array` with the payoff values for player 0 in the tournament game given a random tournament graph in CSR format. Parameters ---------- payoff_array : ndarray(float, ndim=2) ndarray of shape (n, m), where m = n choose k, prefilled with zeros. Modified in place. k : s...
[ "Populate", "payoff_array", "with", "the", "payoff", "values", "for", "player", "0", "in", "the", "tournament", "game", "given", "a", "random", "tournament", "graph", "in", "CSR", "format", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/game_theory/game_generators/bimatrix_generators.py#L473-L505
train
Populate payoff_array with payoff values for player 0 in the tournament game given a random tournament graph.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/game_theory/game_generators/bimatrix_generators.py
_populate_tournament_payoff_array1
def _populate_tournament_payoff_array1(payoff_array, k): """ Populate `payoff_array` with the payoff values for player 1 in the tournament game. Parameters ---------- payoff_array : ndarray(float, ndim=2) ndarray of shape (m, n), where m = n choose k, prefilled with zeros. Modif...
python
def _populate_tournament_payoff_array1(payoff_array, k): """ Populate `payoff_array` with the payoff values for player 1 in the tournament game. Parameters ---------- payoff_array : ndarray(float, ndim=2) ndarray of shape (m, n), where m = n choose k, prefilled with zeros. Modif...
[ "def", "_populate_tournament_payoff_array1", "(", "payoff_array", ",", "k", ")", ":", "m", "=", "payoff_array", ".", "shape", "[", "0", "]", "X", "=", "np", ".", "arange", "(", "k", ")", "for", "j", "in", "range", "(", "m", ")", ":", "for", "i", "i...
Populate `payoff_array` with the payoff values for player 1 in the tournament game. Parameters ---------- payoff_array : ndarray(float, ndim=2) ndarray of shape (m, n), where m = n choose k, prefilled with zeros. Modified in place. k : scalar(int) Size of the subsets of node...
[ "Populate", "payoff_array", "with", "the", "payoff", "values", "for", "player", "1", "in", "the", "tournament", "game", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/game_theory/game_generators/bimatrix_generators.py#L509-L528
train
Populate payoff_array with the payoff values for player 1 in the tournament game.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/game_theory/game_generators/bimatrix_generators.py
unit_vector_game
def unit_vector_game(n, avoid_pure_nash=False, random_state=None): """ Return a NormalFormGame instance of the 2-player game "unit vector game" (Savani and von Stengel, 2016). Payoffs for player 1 are chosen randomly from the [0, 1) range. For player 0, each column contains exactly one 1 payoff and ...
python
def unit_vector_game(n, avoid_pure_nash=False, random_state=None): """ Return a NormalFormGame instance of the 2-player game "unit vector game" (Savani and von Stengel, 2016). Payoffs for player 1 are chosen randomly from the [0, 1) range. For player 0, each column contains exactly one 1 payoff and ...
[ "def", "unit_vector_game", "(", "n", ",", "avoid_pure_nash", "=", "False", ",", "random_state", "=", "None", ")", ":", "random_state", "=", "check_random_state", "(", "random_state", ")", "payoff_arrays", "=", "(", "np", ".", "zeros", "(", "(", "n", ",", "...
Return a NormalFormGame instance of the 2-player game "unit vector game" (Savani and von Stengel, 2016). Payoffs for player 1 are chosen randomly from the [0, 1) range. For player 0, each column contains exactly one 1 payoff and the rest is 0. Parameters ---------- n : scalar(int) Numbe...
[ "Return", "a", "NormalFormGame", "instance", "of", "the", "2", "-", "player", "game", "unit", "vector", "game", "(", "Savani", "and", "von", "Stengel", "2016", ")", ".", "Payoffs", "for", "player", "1", "are", "chosen", "randomly", "from", "the", "[", "0...
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/game_theory/game_generators/bimatrix_generators.py#L531-L615
train
Returns a NormalFormGame instance of the 2 - player game unit vector game.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/markov/gth_solve.py
gth_solve
def gth_solve(A, overwrite=False, use_jit=True): r""" This routine computes the stationary distribution of an irreducible Markov transition matrix (stochastic matrix) or transition rate matrix (generator matrix) `A`. More generally, given a Metzler matrix (square matrix whose off-diagonal entri...
python
def gth_solve(A, overwrite=False, use_jit=True): r""" This routine computes the stationary distribution of an irreducible Markov transition matrix (stochastic matrix) or transition rate matrix (generator matrix) `A`. More generally, given a Metzler matrix (square matrix whose off-diagonal entri...
[ "def", "gth_solve", "(", "A", ",", "overwrite", "=", "False", ",", "use_jit", "=", "True", ")", ":", "A1", "=", "np", ".", "array", "(", "A", ",", "dtype", "=", "float", ",", "copy", "=", "not", "overwrite", ",", "order", "=", "'C'", ")", "# `ord...
r""" This routine computes the stationary distribution of an irreducible Markov transition matrix (stochastic matrix) or transition rate matrix (generator matrix) `A`. More generally, given a Metzler matrix (square matrix whose off-diagonal entries are all nonnegative) `A`, this routine solves ...
[ "r", "This", "routine", "computes", "the", "stationary", "distribution", "of", "an", "irreducible", "Markov", "transition", "matrix", "(", "stochastic", "matrix", ")", "or", "transition", "rate", "matrix", "(", "generator", "matrix", ")", "A", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/markov/gth_solve.py#L9-L91
train
r Solve the Grassmann - Taksar - Heyman - GTH algorithm for a given irreducible markov transition matrix or generator matrix.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/markov/gth_solve.py
_gth_solve_jit
def _gth_solve_jit(A, out): """ JIT complied version of the main routine of gth_solve. Parameters ---------- A : numpy.ndarray(float, ndim=2) Stochastic matrix or generator matrix. Must be of shape n x n. Data will be overwritten. out : numpy.ndarray(float, ndim=1) Outp...
python
def _gth_solve_jit(A, out): """ JIT complied version of the main routine of gth_solve. Parameters ---------- A : numpy.ndarray(float, ndim=2) Stochastic matrix or generator matrix. Must be of shape n x n. Data will be overwritten. out : numpy.ndarray(float, ndim=1) Outp...
[ "def", "_gth_solve_jit", "(", "A", ",", "out", ")", ":", "n", "=", "A", ".", "shape", "[", "0", "]", "# === Reduction === #", "for", "k", "in", "range", "(", "n", "-", "1", ")", ":", "scale", "=", "np", ".", "sum", "(", "A", "[", "k", ",", "k...
JIT complied version of the main routine of gth_solve. Parameters ---------- A : numpy.ndarray(float, ndim=2) Stochastic matrix or generator matrix. Must be of shape n x n. Data will be overwritten. out : numpy.ndarray(float, ndim=1) Output array in which to place the stationar...
[ "JIT", "complied", "version", "of", "the", "main", "routine", "of", "gth_solve", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/markov/gth_solve.py#L95-L135
train
This function is the main routine of the gth_solve function. It is the main routine of the gth_solve function.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/graph_tools.py
_csr_matrix_indices
def _csr_matrix_indices(S): """ Generate the indices of nonzero entries of a csr_matrix S """ m, n = S.shape for i in range(m): for j in range(S.indptr[i], S.indptr[i+1]): row_index, col_index = i, S.indices[j] yield row_index, col_index
python
def _csr_matrix_indices(S): """ Generate the indices of nonzero entries of a csr_matrix S """ m, n = S.shape for i in range(m): for j in range(S.indptr[i], S.indptr[i+1]): row_index, col_index = i, S.indices[j] yield row_index, col_index
[ "def", "_csr_matrix_indices", "(", "S", ")", ":", "m", ",", "n", "=", "S", ".", "shape", "for", "i", "in", "range", "(", "m", ")", ":", "for", "j", "in", "range", "(", "S", ".", "indptr", "[", "i", "]", ",", "S", ".", "indptr", "[", "i", "+...
Generate the indices of nonzero entries of a csr_matrix S
[ "Generate", "the", "indices", "of", "nonzero", "entries", "of", "a", "csr_matrix", "S" ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/graph_tools.py#L362-L372
train
Generate the indices of nonzero entries of a csr_matrix S
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/graph_tools.py
random_tournament_graph
def random_tournament_graph(n, random_state=None): """ Return a random tournament graph [1]_ with n nodes. Parameters ---------- n : scalar(int) Number of nodes. random_state : int or np.random.RandomState, optional Random seed (integer) or np.random.RandomState instance to set...
python
def random_tournament_graph(n, random_state=None): """ Return a random tournament graph [1]_ with n nodes. Parameters ---------- n : scalar(int) Number of nodes. random_state : int or np.random.RandomState, optional Random seed (integer) or np.random.RandomState instance to set...
[ "def", "random_tournament_graph", "(", "n", ",", "random_state", "=", "None", ")", ":", "random_state", "=", "check_random_state", "(", "random_state", ")", "num_edges", "=", "n", "*", "(", "n", "-", "1", ")", "//", "2", "r", "=", "random_state", ".", "r...
Return a random tournament graph [1]_ with n nodes. Parameters ---------- n : scalar(int) Number of nodes. random_state : int or np.random.RandomState, optional Random seed (integer) or np.random.RandomState instance to set the initial state of the random number generator for ...
[ "Return", "a", "random", "tournament", "graph", "[", "1", "]", "_", "with", "n", "nodes", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/graph_tools.py#L375-L410
train
Generate a random tournament graph with n nodes.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/graph_tools.py
_populate_random_tournament_row_col
def _populate_random_tournament_row_col(n, r, row, col): """ Populate ndarrays `row` and `col` with directed edge indices determined by random numbers in `r` for a tournament graph with n nodes, which has num_edges = n * (n-1) // 2 edges. Parameters ---------- n : scalar(int) Number...
python
def _populate_random_tournament_row_col(n, r, row, col): """ Populate ndarrays `row` and `col` with directed edge indices determined by random numbers in `r` for a tournament graph with n nodes, which has num_edges = n * (n-1) // 2 edges. Parameters ---------- n : scalar(int) Number...
[ "def", "_populate_random_tournament_row_col", "(", "n", ",", "r", ",", "row", ",", "col", ")", ":", "k", "=", "0", "for", "i", "in", "range", "(", "n", ")", ":", "for", "j", "in", "range", "(", "i", "+", "1", ",", "n", ")", ":", "if", "r", "[...
Populate ndarrays `row` and `col` with directed edge indices determined by random numbers in `r` for a tournament graph with n nodes, which has num_edges = n * (n-1) // 2 edges. Parameters ---------- n : scalar(int) Number of nodes. r : ndarray(float, ndim=1) ndarray of length ...
[ "Populate", "ndarrays", "row", "and", "col", "with", "directed", "edge", "indices", "determined", "by", "random", "numbers", "in", "r", "for", "a", "tournament", "graph", "with", "n", "nodes", "which", "has", "num_edges", "=", "n", "*", "(", "n", "-", "1...
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/graph_tools.py#L414-L439
train
Populate row and col with random numbers in r.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/graph_tools.py
DiGraph._find_scc
def _find_scc(self): """ Set ``self._num_scc`` and ``self._scc_proj`` by calling ``scipy.sparse.csgraph.connected_components``: * docs.scipy.org/doc/scipy/reference/sparse.csgraph.html * github.com/scipy/scipy/blob/master/scipy/sparse/csgraph/_traversal.pyx ``self._scc_p...
python
def _find_scc(self): """ Set ``self._num_scc`` and ``self._scc_proj`` by calling ``scipy.sparse.csgraph.connected_components``: * docs.scipy.org/doc/scipy/reference/sparse.csgraph.html * github.com/scipy/scipy/blob/master/scipy/sparse/csgraph/_traversal.pyx ``self._scc_p...
[ "def", "_find_scc", "(", "self", ")", ":", "# Find the strongly connected components", "self", ".", "_num_scc", ",", "self", ".", "_scc_proj", "=", "csgraph", ".", "connected_components", "(", "self", ".", "csgraph", ",", "connection", "=", "'strong'", ")" ]
Set ``self._num_scc`` and ``self._scc_proj`` by calling ``scipy.sparse.csgraph.connected_components``: * docs.scipy.org/doc/scipy/reference/sparse.csgraph.html * github.com/scipy/scipy/blob/master/scipy/sparse/csgraph/_traversal.pyx ``self._scc_proj`` is a list of length `n` that assign...
[ "Set", "self", ".", "_num_scc", "and", "self", ".", "_scc_proj", "by", "calling", "scipy", ".", "sparse", ".", "csgraph", ".", "connected_components", ":", "*", "docs", ".", "scipy", ".", "org", "/", "doc", "/", "scipy", "/", "reference", "/", "sparse", ...
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/graph_tools.py#L151-L164
train
Find strongly connected components for this node.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/graph_tools.py
DiGraph._condensation_lil
def _condensation_lil(self): """ Return the sparse matrix representation of the condensation digraph in lil format. """ condensation_lil = sparse.lil_matrix( (self.num_strongly_connected_components, self.num_strongly_connected_components), dtype=bool ...
python
def _condensation_lil(self): """ Return the sparse matrix representation of the condensation digraph in lil format. """ condensation_lil = sparse.lil_matrix( (self.num_strongly_connected_components, self.num_strongly_connected_components), dtype=bool ...
[ "def", "_condensation_lil", "(", "self", ")", ":", "condensation_lil", "=", "sparse", ".", "lil_matrix", "(", "(", "self", ".", "num_strongly_connected_components", ",", "self", ".", "num_strongly_connected_components", ")", ",", "dtype", "=", "bool", ")", "scc_pr...
Return the sparse matrix representation of the condensation digraph in lil format.
[ "Return", "the", "sparse", "matrix", "representation", "of", "the", "condensation", "digraph", "in", "lil", "format", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/graph_tools.py#L182-L199
train
Return the sparse matrix representation of the condensation digraph in lil format.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/graph_tools.py
DiGraph._find_sink_scc
def _find_sink_scc(self): """ Set self._sink_scc_labels, which is a list containing the labels of the strongly connected components. """ condensation_lil = self._condensation_lil() # A sink SCC is a SCC such that none of its members is strongly # connected to no...
python
def _find_sink_scc(self): """ Set self._sink_scc_labels, which is a list containing the labels of the strongly connected components. """ condensation_lil = self._condensation_lil() # A sink SCC is a SCC such that none of its members is strongly # connected to no...
[ "def", "_find_sink_scc", "(", "self", ")", ":", "condensation_lil", "=", "self", ".", "_condensation_lil", "(", ")", "# A sink SCC is a SCC such that none of its members is strongly", "# connected to nodes in other SCCs", "# Those k's such that graph_condensed_lil.rows[k] == []", "se...
Set self._sink_scc_labels, which is a list containing the labels of the strongly connected components.
[ "Set", "self", ".", "_sink_scc_labels", "which", "is", "a", "list", "containing", "the", "labels", "of", "the", "strongly", "connected", "components", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/graph_tools.py#L201-L213
train
Find the sink SCC that is strongly connected to the other SCCs.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/graph_tools.py
DiGraph._compute_period
def _compute_period(self): """ Set ``self._period`` and ``self._cyclic_components_proj``. Use the algorithm described in: J. P. Jarvis and D. R. Shier, "Graph-Theoretic Analysis of Finite Markov Chains," 1996. """ # Degenerate graph with a single node (which is ...
python
def _compute_period(self): """ Set ``self._period`` and ``self._cyclic_components_proj``. Use the algorithm described in: J. P. Jarvis and D. R. Shier, "Graph-Theoretic Analysis of Finite Markov Chains," 1996. """ # Degenerate graph with a single node (which is ...
[ "def", "_compute_period", "(", "self", ")", ":", "# Degenerate graph with a single node (which is strongly connected)", "# csgraph.reconstruct_path would raise an exception", "# github.com/scipy/scipy/issues/4018", "if", "self", ".", "n", "==", "1", ":", "if", "self", ".", "csg...
Set ``self._period`` and ``self._cyclic_components_proj``. Use the algorithm described in: J. P. Jarvis and D. R. Shier, "Graph-Theoretic Analysis of Finite Markov Chains," 1996.
[ "Set", "self", ".", "_period", "and", "self", ".", "_cyclic_components_proj", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/graph_tools.py#L251-L309
train
Compute the period of the tree.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/graph_tools.py
DiGraph.subgraph
def subgraph(self, nodes): """ Return the subgraph consisting of the given nodes and edges between thses nodes. Parameters ---------- nodes : array_like(int, ndim=1) Array of node indices. Returns ------- DiGraph A DiGraph ...
python
def subgraph(self, nodes): """ Return the subgraph consisting of the given nodes and edges between thses nodes. Parameters ---------- nodes : array_like(int, ndim=1) Array of node indices. Returns ------- DiGraph A DiGraph ...
[ "def", "subgraph", "(", "self", ",", "nodes", ")", ":", "adj_matrix", "=", "self", ".", "csgraph", "[", "np", ".", "ix_", "(", "nodes", ",", "nodes", ")", "]", "weighted", "=", "True", "# To copy the dtype", "if", "self", ".", "node_labels", "is", "not...
Return the subgraph consisting of the given nodes and edges between thses nodes. Parameters ---------- nodes : array_like(int, ndim=1) Array of node indices. Returns ------- DiGraph A DiGraph representing the subgraph.
[ "Return", "the", "subgraph", "consisting", "of", "the", "given", "nodes", "and", "edges", "between", "thses", "nodes", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/graph_tools.py#L334-L359
train
Returns the subgraph consisting of the given nodes and edges between thses nodes.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/rank_nullspace.py
rank_est
def rank_est(A, atol=1e-13, rtol=0): """ Estimate the rank (i.e. the dimension of the nullspace) of a matrix. The algorithm used by this function is based on the singular value decomposition of `A`. Parameters ---------- A : array_like(float, ndim=1 or 2) A should be at most 2-D. ...
python
def rank_est(A, atol=1e-13, rtol=0): """ Estimate the rank (i.e. the dimension of the nullspace) of a matrix. The algorithm used by this function is based on the singular value decomposition of `A`. Parameters ---------- A : array_like(float, ndim=1 or 2) A should be at most 2-D. ...
[ "def", "rank_est", "(", "A", ",", "atol", "=", "1e-13", ",", "rtol", "=", "0", ")", ":", "A", "=", "np", ".", "atleast_2d", "(", "A", ")", "s", "=", "svd", "(", "A", ",", "compute_uv", "=", "False", ")", "tol", "=", "max", "(", "atol", ",", ...
Estimate the rank (i.e. the dimension of the nullspace) of a matrix. The algorithm used by this function is based on the singular value decomposition of `A`. Parameters ---------- A : array_like(float, ndim=1 or 2) A should be at most 2-D. A 1-D array with length n will be treated...
[ "Estimate", "the", "rank", "(", "i", ".", "e", ".", "the", "dimension", "of", "the", "nullspace", ")", "of", "a", "matrix", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/rank_nullspace.py#L5-L49
train
Estimate the rank of a matrix.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/filter.py
hamilton_filter
def hamilton_filter(data, h, *args): r""" This function applies "Hamilton filter" to the data http://econweb.ucsd.edu/~jhamilto/hp.pdf Parameters ---------- data : arrray or dataframe h : integer Time horizon that we are likely to predict incorrectly. Ori...
python
def hamilton_filter(data, h, *args): r""" This function applies "Hamilton filter" to the data http://econweb.ucsd.edu/~jhamilto/hp.pdf Parameters ---------- data : arrray or dataframe h : integer Time horizon that we are likely to predict incorrectly. Ori...
[ "def", "hamilton_filter", "(", "data", ",", "h", ",", "*", "args", ")", ":", "# transform data to array\r", "y", "=", "np", ".", "asarray", "(", "data", ",", "float", ")", "# sample size\r", "T", "=", "len", "(", "y", ")", "if", "len", "(", "args", "...
r""" This function applies "Hamilton filter" to the data http://econweb.ucsd.edu/~jhamilto/hp.pdf Parameters ---------- data : arrray or dataframe h : integer Time horizon that we are likely to predict incorrectly. Original paper recommends 2 for annual data, ...
[ "r", "This", "function", "applies", "Hamilton", "filter", "to", "the", "data", "http", ":", "//", "econweb", ".", "ucsd", ".", "edu", "/", "~jhamilto", "/", "hp", ".", "pdf", "Parameters", "----------", "data", ":", "arrray", "or", "dataframe", "h", ":",...
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/filter.py#L8-L59
train
r Hamilton filter
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/markov/utilities.py
sa_indices
def sa_indices(num_states, num_actions): """ Generate `s_indices` and `a_indices` for `DiscreteDP`, for the case where all the actions are feasible at every state. Parameters ---------- num_states : scalar(int) Number of states. num_actions : scalar(int) Number of actions. ...
python
def sa_indices(num_states, num_actions): """ Generate `s_indices` and `a_indices` for `DiscreteDP`, for the case where all the actions are feasible at every state. Parameters ---------- num_states : scalar(int) Number of states. num_actions : scalar(int) Number of actions. ...
[ "def", "sa_indices", "(", "num_states", ",", "num_actions", ")", ":", "L", "=", "num_states", "*", "num_actions", "dtype", "=", "np", ".", "int_", "s_indices", "=", "np", ".", "empty", "(", "L", ",", "dtype", "=", "dtype", ")", "a_indices", "=", "np", ...
Generate `s_indices` and `a_indices` for `DiscreteDP`, for the case where all the actions are feasible at every state. Parameters ---------- num_states : scalar(int) Number of states. num_actions : scalar(int) Number of actions. Returns ------- s_indices : ndarray(int,...
[ "Generate", "s_indices", "and", "a_indices", "for", "DiscreteDP", "for", "the", "case", "where", "all", "the", "actions", "are", "feasible", "at", "every", "state", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/markov/utilities.py#L9-L51
train
Generates s_indices and a_indices for the DiscreteDP case.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/markov/core.py
_generate_sample_paths
def _generate_sample_paths(P_cdfs, init_states, random_values, out): """ Generate num_reps sample paths of length ts_length, where num_reps = out.shape[0] and ts_length = out.shape[1]. Parameters ---------- P_cdfs : ndarray(float, ndim=2) Array containing as rows the CDFs of the state t...
python
def _generate_sample_paths(P_cdfs, init_states, random_values, out): """ Generate num_reps sample paths of length ts_length, where num_reps = out.shape[0] and ts_length = out.shape[1]. Parameters ---------- P_cdfs : ndarray(float, ndim=2) Array containing as rows the CDFs of the state t...
[ "def", "_generate_sample_paths", "(", "P_cdfs", ",", "init_states", ",", "random_values", ",", "out", ")", ":", "num_reps", ",", "ts_length", "=", "out", ".", "shape", "for", "i", "in", "range", "(", "num_reps", ")", ":", "out", "[", "i", ",", "0", "]"...
Generate num_reps sample paths of length ts_length, where num_reps = out.shape[0] and ts_length = out.shape[1]. Parameters ---------- P_cdfs : ndarray(float, ndim=2) Array containing as rows the CDFs of the state transition. init_states : array_like(int, ndim=1) Array containing th...
[ "Generate", "num_reps", "sample", "paths", "of", "length", "ts_length", "where", "num_reps", "=", "out", ".", "shape", "[", "0", "]", "and", "ts_length", "=", "out", ".", "shape", "[", "1", "]", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/markov/core.py#L578-L609
train
Generate sample paths for the next state transition.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/markov/core.py
_generate_sample_paths_sparse
def _generate_sample_paths_sparse(P_cdfs1d, indices, indptr, init_states, random_values, out): """ For sparse matrix. Generate num_reps sample paths of length ts_length, where num_reps = out.shape[0] and ts_length = out.shape[1]. Parameters ---------- P_cd...
python
def _generate_sample_paths_sparse(P_cdfs1d, indices, indptr, init_states, random_values, out): """ For sparse matrix. Generate num_reps sample paths of length ts_length, where num_reps = out.shape[0] and ts_length = out.shape[1]. Parameters ---------- P_cd...
[ "def", "_generate_sample_paths_sparse", "(", "P_cdfs1d", ",", "indices", ",", "indptr", ",", "init_states", ",", "random_values", ",", "out", ")", ":", "num_reps", ",", "ts_length", "=", "out", ".", "shape", "for", "i", "in", "range", "(", "num_reps", ")", ...
For sparse matrix. Generate num_reps sample paths of length ts_length, where num_reps = out.shape[0] and ts_length = out.shape[1]. Parameters ---------- P_cdfs1d : ndarray(float, ndim=1) 1D array containing the CDFs of the state transition. indices : ndarray(int, ndim=1) CSR f...
[ "For", "sparse", "matrix", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/markov/core.py#L613-L655
train
Generate sample paths for sparse matrix.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/markov/core.py
mc_sample_path
def mc_sample_path(P, init=0, sample_size=1000, random_state=None): """ Generates one sample path from the Markov chain represented by (n x n) transition matrix P on state space S = {{0,...,n-1}}. Parameters ---------- P : array_like(float, ndim=2) A Markov transition matrix. init ...
python
def mc_sample_path(P, init=0, sample_size=1000, random_state=None): """ Generates one sample path from the Markov chain represented by (n x n) transition matrix P on state space S = {{0,...,n-1}}. Parameters ---------- P : array_like(float, ndim=2) A Markov transition matrix. init ...
[ "def", "mc_sample_path", "(", "P", ",", "init", "=", "0", ",", "sample_size", "=", "1000", ",", "random_state", "=", "None", ")", ":", "random_state", "=", "check_random_state", "(", "random_state", ")", "if", "isinstance", "(", "init", ",", "numbers", "."...
Generates one sample path from the Markov chain represented by (n x n) transition matrix P on state space S = {{0,...,n-1}}. Parameters ---------- P : array_like(float, ndim=2) A Markov transition matrix. init : array_like(float ndim=1) or scalar(int), optional(default=0) If init i...
[ "Generates", "one", "sample", "path", "from", "the", "Markov", "chain", "represented", "by", "(", "n", "x", "n", ")", "transition", "matrix", "P", "on", "state", "space", "S", "=", "{{", "0", "...", "n", "-", "1", "}}", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/markov/core.py#L673-L714
train
Generates one sample path from the Markov chain represented by a Markov transition matrix P on state space S.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/markov/core.py
MarkovChain.get_index
def get_index(self, value): """ Return the index (or indices) of the given value (or values) in `state_values`. Parameters ---------- value Value(s) to get the index (indices) for. Returns ------- idx : int or ndarray(int) ...
python
def get_index(self, value): """ Return the index (or indices) of the given value (or values) in `state_values`. Parameters ---------- value Value(s) to get the index (indices) for. Returns ------- idx : int or ndarray(int) ...
[ "def", "get_index", "(", "self", ",", "value", ")", ":", "if", "self", ".", "state_values", "is", "None", ":", "state_values_ndim", "=", "1", "else", ":", "state_values_ndim", "=", "self", ".", "state_values", ".", "ndim", "values", "=", "np", ".", "asar...
Return the index (or indices) of the given value (or values) in `state_values`. Parameters ---------- value Value(s) to get the index (indices) for. Returns ------- idx : int or ndarray(int) Index of `value` if `value` is a single state v...
[ "Return", "the", "index", "(", "or", "indices", ")", "of", "the", "given", "value", "(", "or", "values", ")", "in", "state_values", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/markov/core.py#L241-L274
train
Returns the index of the given value or values in the state_values array.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/markov/core.py
MarkovChain._get_index
def _get_index(self, value): """ Return the index of the given value in `state_values`. Parameters ---------- value Value to get the index for. Returns ------- idx : int Index of `value`. """ error_msg = 'value {0...
python
def _get_index(self, value): """ Return the index of the given value in `state_values`. Parameters ---------- value Value to get the index for. Returns ------- idx : int Index of `value`. """ error_msg = 'value {0...
[ "def", "_get_index", "(", "self", ",", "value", ")", ":", "error_msg", "=", "'value {0} not found'", ".", "format", "(", "value", ")", "if", "self", ".", "state_values", "is", "None", ":", "if", "isinstance", "(", "value", ",", "numbers", ".", "Integral", ...
Return the index of the given value in `state_values`. Parameters ---------- value Value to get the index for. Returns ------- idx : int Index of `value`.
[ "Return", "the", "index", "of", "the", "given", "value", "in", "state_values", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/markov/core.py#L277-L313
train
Return the index of the given value in state_values.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
QuantEcon/QuantEcon.py
quantecon/markov/core.py
MarkovChain._compute_stationary
def _compute_stationary(self): """ Store the stationary distributions in self._stationary_distributions. """ if self.is_irreducible: if not self.is_sparse: # Dense stationary_dists = gth_solve(self.P).reshape(1, self.n) else: # Sparse ...
python
def _compute_stationary(self): """ Store the stationary distributions in self._stationary_distributions. """ if self.is_irreducible: if not self.is_sparse: # Dense stationary_dists = gth_solve(self.P).reshape(1, self.n) else: # Sparse ...
[ "def", "_compute_stationary", "(", "self", ")", ":", "if", "self", ".", "is_irreducible", ":", "if", "not", "self", ".", "is_sparse", ":", "# Dense", "stationary_dists", "=", "gth_solve", "(", "self", ".", "P", ")", ".", "reshape", "(", "1", ",", "self",...
Store the stationary distributions in self._stationary_distributions.
[ "Store", "the", "stationary", "distributions", "in", "self", ".", "_stationary_distributions", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/markov/core.py#L389-L411
train
Compute the stationary distributions for the current class.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...