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
QuantEcon/QuantEcon.py
quantecon/markov/core.py
MarkovChain.simulate_indices
def simulate_indices(self, ts_length, init=None, num_reps=None, random_state=None): """ Simulate time series of state transitions, where state indices are returned. Parameters ---------- ts_length : scalar(int) Length of each simulati...
python
def simulate_indices(self, ts_length, init=None, num_reps=None, random_state=None): """ Simulate time series of state transitions, where state indices are returned. Parameters ---------- ts_length : scalar(int) Length of each simulati...
[ "def", "simulate_indices", "(", "self", ",", "ts_length", ",", "init", "=", "None", ",", "num_reps", "=", "None", ",", "random_state", "=", "None", ")", ":", "random_state", "=", "check_random_state", "(", "random_state", ")", "dim", "=", "1", "# Dimension o...
Simulate time series of state transitions, where state indices are returned. Parameters ---------- ts_length : scalar(int) Length of each simulation. init : int or array_like(int, ndim=1), optional Initial state(s). If None, the initial state is randomly...
[ "Simulate", "time", "series", "of", "state", "transitions", "where", "state", "indices", "are", "returned", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/markov/core.py#L441-L527
train
Simulate time series of state transitions where state indices are returned.
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.simulate
def simulate(self, ts_length, init=None, num_reps=None, random_state=None): """ Simulate time series of state transitions, where the states are annotated with their values (if `state_values` is not None). Parameters ---------- ts_length : scalar(int) Length o...
python
def simulate(self, ts_length, init=None, num_reps=None, random_state=None): """ Simulate time series of state transitions, where the states are annotated with their values (if `state_values` is not None). Parameters ---------- ts_length : scalar(int) Length o...
[ "def", "simulate", "(", "self", ",", "ts_length", ",", "init", "=", "None", ",", "num_reps", "=", "None", ",", "random_state", "=", "None", ")", ":", "if", "init", "is", "not", "None", ":", "init_idx", "=", "self", ".", "get_index", "(", "init", ")",...
Simulate time series of state transitions, where the states are annotated with their values (if `state_values` is not None). Parameters ---------- ts_length : scalar(int) Length of each simulation. init : scalar or array_like, optional(default=None) Init...
[ "Simulate", "time", "series", "of", "state", "transitions", "where", "the", "states", "are", "annotated", "with", "their", "values", "(", "if", "state_values", "is", "not", "None", ")", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/markov/core.py#L529-L574
train
Simulate the time series of state transitions.
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/lqcontrol.py
LQ.stationary_values
def stationary_values(self, method='doubling'): """ Computes the matrix :math:`P` and scalar :math:`d` that represent the value function .. math:: V(x) = x' P x + d in the infinite horizon case. Also computes the control matrix :math:`F` from :math:`u = -...
python
def stationary_values(self, method='doubling'): """ Computes the matrix :math:`P` and scalar :math:`d` that represent the value function .. math:: V(x) = x' P x + d in the infinite horizon case. Also computes the control matrix :math:`F` from :math:`u = -...
[ "def", "stationary_values", "(", "self", ",", "method", "=", "'doubling'", ")", ":", "# === simplify notation === #", "Q", ",", "R", ",", "A", ",", "B", ",", "N", ",", "C", "=", "self", ".", "Q", ",", "self", ".", "R", ",", "self", ".", "A", ",", ...
Computes the matrix :math:`P` and scalar :math:`d` that represent the value function .. math:: V(x) = x' P x + d in the infinite horizon case. Also computes the control matrix :math:`F` from :math:`u = - Fx`. Computation is via the solution algorithm as specified...
[ "Computes", "the", "matrix", ":", "math", ":", "P", "and", "scalar", ":", "math", ":", "d", "that", "represent", "the", "value", "function" ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/lqcontrol.py#L195-L247
train
Computes the stationary values of the control set entry for the current entry.
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/pure_nash.py
pure_nash_brute_gen
def pure_nash_brute_gen(g, tol=None): """ Generator version of `pure_nash_brute`. Parameters ---------- g : NormalFormGame tol : scalar(float), optional(default=None) Tolerance level used in determining best responses. If None, default to the value of the `tol` attribute of `g`....
python
def pure_nash_brute_gen(g, tol=None): """ Generator version of `pure_nash_brute`. Parameters ---------- g : NormalFormGame tol : scalar(float), optional(default=None) Tolerance level used in determining best responses. If None, default to the value of the `tol` attribute of `g`....
[ "def", "pure_nash_brute_gen", "(", "g", ",", "tol", "=", "None", ")", ":", "for", "a", "in", "np", ".", "ndindex", "(", "*", "g", ".", "nums_actions", ")", ":", "if", "g", ".", "is_nash", "(", "a", ",", "tol", "=", "tol", ")", ":", "yield", "a"...
Generator version of `pure_nash_brute`. Parameters ---------- g : NormalFormGame tol : scalar(float), optional(default=None) Tolerance level used in determining best responses. If None, default to the value of the `tol` attribute of `g`. Yields ------ out : tuple(int) ...
[ "Generator", "version", "of", "pure_nash_brute", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/game_theory/pure_nash.py#L50-L69
train
Generator version of pure_nash_brute.
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/quad.py
qnwequi
def qnwequi(n, a, b, kind="N", equidist_pp=None, random_state=None): """ Generates equidistributed sequences with property that averages value of integrable function evaluated over the sequence converges to the integral as n goes to infinity. Parameters ---------- n : int Number of ...
python
def qnwequi(n, a, b, kind="N", equidist_pp=None, random_state=None): """ Generates equidistributed sequences with property that averages value of integrable function evaluated over the sequence converges to the integral as n goes to infinity. Parameters ---------- n : int Number of ...
[ "def", "qnwequi", "(", "n", ",", "a", ",", "b", ",", "kind", "=", "\"N\"", ",", "equidist_pp", "=", "None", ",", "random_state", "=", "None", ")", ":", "random_state", "=", "check_random_state", "(", "random_state", ")", "if", "equidist_pp", "is", "None"...
Generates equidistributed sequences with property that averages value of integrable function evaluated over the sequence converges to the integral as n goes to infinity. Parameters ---------- n : int Number of sequence points a : scalar or array_like(float) A length-d iterable ...
[ "Generates", "equidistributed", "sequences", "with", "property", "that", "averages", "value", "of", "integrable", "function", "evaluated", "over", "the", "sequence", "converges", "to", "the", "integral", "as", "n", "goes", "to", "infinity", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/quad.py#L83-L181
train
Generates equidistributed sequences with property that averages over the integral as n goes to infinity.
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/quad.py
qnwnorm
def qnwnorm(n, mu=None, sig2=None, usesqrtm=False): """ Computes nodes and weights for multivariate normal distribution Parameters ---------- n : int or array_like(float) A length-d iterable of the number of nodes in each dimension mu : scalar or array_like(float), optional(default=zer...
python
def qnwnorm(n, mu=None, sig2=None, usesqrtm=False): """ Computes nodes and weights for multivariate normal distribution Parameters ---------- n : int or array_like(float) A length-d iterable of the number of nodes in each dimension mu : scalar or array_like(float), optional(default=zer...
[ "def", "qnwnorm", "(", "n", ",", "mu", "=", "None", ",", "sig2", "=", "None", ",", "usesqrtm", "=", "False", ")", ":", "n", "=", "np", ".", "atleast_1d", "(", "n", ")", "d", "=", "n", ".", "size", "if", "mu", "is", "None", ":", "mu", "=", "...
Computes nodes and weights for multivariate normal distribution Parameters ---------- n : int or array_like(float) A length-d iterable of the number of nodes in each dimension mu : scalar or array_like(float), optional(default=zeros(d)) The means of each dimension of the random variabl...
[ "Computes", "nodes", "and", "weights", "for", "multivariate", "normal", "distribution" ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/quad.py#L225-L299
train
Computes the multivariate normal distribution of a multivariate normal distribution.
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/quad.py
qnwlogn
def qnwlogn(n, mu=None, sig2=None): """ Computes nodes and weights for multivariate lognormal distribution Parameters ---------- n : int or array_like(float) A length-d iterable of the number of nodes in each dimension mu : scalar or array_like(float), optional(default=zeros(d)) ...
python
def qnwlogn(n, mu=None, sig2=None): """ Computes nodes and weights for multivariate lognormal distribution Parameters ---------- n : int or array_like(float) A length-d iterable of the number of nodes in each dimension mu : scalar or array_like(float), optional(default=zeros(d)) ...
[ "def", "qnwlogn", "(", "n", ",", "mu", "=", "None", ",", "sig2", "=", "None", ")", ":", "nodes", ",", "weights", "=", "qnwnorm", "(", "n", ",", "mu", ",", "sig2", ")", "return", "np", ".", "exp", "(", "nodes", ")", ",", "weights" ]
Computes nodes and weights for multivariate lognormal distribution Parameters ---------- n : int or array_like(float) A length-d iterable of the number of nodes in each dimension mu : scalar or array_like(float), optional(default=zeros(d)) The means of each dimension of the random vari...
[ "Computes", "nodes", "and", "weights", "for", "multivariate", "lognormal", "distribution" ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/quad.py#L302-L340
train
Returns the nodes and weights for a multivariate lognormal distribution.
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/quad.py
qnwunif
def qnwunif(n, a, b): """ Computes quadrature nodes and weights for multivariate uniform distribution Parameters ---------- n : int or array_like(float) A length-d iterable of the number of nodes in each dimension a : scalar or array_like(float) A length-d iterable of lower...
python
def qnwunif(n, a, b): """ Computes quadrature nodes and weights for multivariate uniform distribution Parameters ---------- n : int or array_like(float) A length-d iterable of the number of nodes in each dimension a : scalar or array_like(float) A length-d iterable of lower...
[ "def", "qnwunif", "(", "n", ",", "a", ",", "b", ")", ":", "n", ",", "a", ",", "b", "=", "list", "(", "map", "(", "np", ".", "asarray", ",", "[", "n", ",", "a", ",", "b", "]", ")", ")", "nodes", ",", "weights", "=", "qnwlege", "(", "n", ...
Computes quadrature nodes and weights for multivariate uniform distribution Parameters ---------- n : int or array_like(float) A length-d iterable of the number of nodes in each dimension a : scalar or array_like(float) A length-d iterable of lower endpoints. If a scalar is given, ...
[ "Computes", "quadrature", "nodes", "and", "weights", "for", "multivariate", "uniform", "distribution" ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/quad.py#L425-L467
train
Computes the quadrature nodes and weights for a multivariate uniform distribution.
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/quad.py
quadrect
def quadrect(f, n, a, b, kind='lege', *args, **kwargs): """ Integrate the d-dimensional function f on a rectangle with lower and upper bound for dimension i defined by a[i] and b[i], respectively; using n[i] points. Parameters ---------- f : function The function to integrate over. ...
python
def quadrect(f, n, a, b, kind='lege', *args, **kwargs): """ Integrate the d-dimensional function f on a rectangle with lower and upper bound for dimension i defined by a[i] and b[i], respectively; using n[i] points. Parameters ---------- f : function The function to integrate over. ...
[ "def", "quadrect", "(", "f", ",", "n", ",", "a", ",", "b", ",", "kind", "=", "'lege'", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "kind", ".", "lower", "(", ")", "==", "\"lege\"", ":", "nodes", ",", "weights", "=", "qnwlege", ...
Integrate the d-dimensional function f on a rectangle with lower and upper bound for dimension i defined by a[i] and b[i], respectively; using n[i] points. Parameters ---------- f : function The function to integrate over. This should be a function that accepts as its first argument...
[ "Integrate", "the", "d", "-", "dimensional", "function", "f", "on", "a", "rectangle", "with", "lower", "and", "upper", "bound", "for", "dimension", "i", "defined", "by", "a", "[", "i", "]", "and", "b", "[", "i", "]", "respectively", ";", "using", "n", ...
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/quad.py#L470-L542
train
Integrate a d - dimensional function f on a rectangle with lower and upper bound for dimension a and b.
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/quad.py
qnwgamma
def qnwgamma(n, a=1.0, b=1.0, tol=3e-14): """ Computes nodes and weights for gamma distribution Parameters ---------- n : int or array_like(float) A length-d iterable of the number of nodes in each dimension a : scalar or array_like(float) : optional(default=ones(d)) Shape para...
python
def qnwgamma(n, a=1.0, b=1.0, tol=3e-14): """ Computes nodes and weights for gamma distribution Parameters ---------- n : int or array_like(float) A length-d iterable of the number of nodes in each dimension a : scalar or array_like(float) : optional(default=ones(d)) Shape para...
[ "def", "qnwgamma", "(", "n", ",", "a", "=", "1.0", ",", "b", "=", "1.0", ",", "tol", "=", "3e-14", ")", ":", "return", "_make_multidim_func", "(", "_qnwgamma1", ",", "n", ",", "a", ",", "b", ",", "tol", ")" ]
Computes nodes and weights for gamma distribution Parameters ---------- n : int or array_like(float) A length-d iterable of the number of nodes in each dimension a : scalar or array_like(float) : optional(default=ones(d)) Shape parameter of the gamma distribution parameter. Must be pos...
[ "Computes", "nodes", "and", "weights", "for", "gamma", "distribution" ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/quad.py#L583-L620
train
Returns a function that computes the nodes and weights for a gamma distribution.
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/quad.py
_make_multidim_func
def _make_multidim_func(one_d_func, n, *args): """ A helper function to cut down on code repetition. Almost all of the code in qnwcheb, qnwlege, qnwsimp, qnwtrap is just dealing various forms of input arguments and then shelling out to the corresponding 1d version of the function. This routine ...
python
def _make_multidim_func(one_d_func, n, *args): """ A helper function to cut down on code repetition. Almost all of the code in qnwcheb, qnwlege, qnwsimp, qnwtrap is just dealing various forms of input arguments and then shelling out to the corresponding 1d version of the function. This routine ...
[ "def", "_make_multidim_func", "(", "one_d_func", ",", "n", ",", "*", "args", ")", ":", "_args", "=", "list", "(", "args", ")", "n", "=", "np", ".", "atleast_1d", "(", "n", ")", "args", "=", "list", "(", "map", "(", "np", ".", "atleast_1d", ",", "...
A helper function to cut down on code repetition. Almost all of the code in qnwcheb, qnwlege, qnwsimp, qnwtrap is just dealing various forms of input arguments and then shelling out to the corresponding 1d version of the function. This routine does all the argument checking and passes things throug...
[ "A", "helper", "function", "to", "cut", "down", "on", "code", "repetition", ".", "Almost", "all", "of", "the", "code", "in", "qnwcheb", "qnwlege", "qnwsimp", "qnwtrap", "is", "just", "dealing", "various", "forms", "of", "input", "arguments", "and", "then", ...
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/quad.py#L627-L682
train
This function is a helper function to cut down on code repetition. It is used to cut down on code repetition.
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/quad.py
_qnwcheb1
def _qnwcheb1(n, a, b): """ Compute univariate Guass-Checbychev quadrature nodes and weights Parameters ---------- n : int The number of nodes a : int The lower endpoint b : int The upper endpoint Returns ------- nodes : np.ndarray(dtype=float) ...
python
def _qnwcheb1(n, a, b): """ Compute univariate Guass-Checbychev quadrature nodes and weights Parameters ---------- n : int The number of nodes a : int The lower endpoint b : int The upper endpoint Returns ------- nodes : np.ndarray(dtype=float) ...
[ "def", "_qnwcheb1", "(", "n", ",", "a", ",", "b", ")", ":", "nodes", "=", "(", "b", "+", "a", ")", "/", "2", "-", "(", "b", "-", "a", ")", "/", "2", "*", "np", ".", "cos", "(", "np", ".", "pi", "/", "n", "*", "np", ".", "linspace", "(...
Compute univariate Guass-Checbychev quadrature nodes and weights Parameters ---------- n : int The number of nodes a : int The lower endpoint b : int The upper endpoint Returns ------- nodes : np.ndarray(dtype=float) An n element array of nodes no...
[ "Compute", "univariate", "Guass", "-", "Checbychev", "quadrature", "nodes", "and", "weights" ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/quad.py#L685-L730
train
Compute univariate Guass - Checbychev quadrature nodes and weights
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/quad.py
_qnwlege1
def _qnwlege1(n, a, b): """ Compute univariate Guass-Legendre quadrature nodes and weights Parameters ---------- n : int The number of nodes a : int The lower endpoint b : int The upper endpoint Returns ------- nodes : np.ndarray(dtype=float) A...
python
def _qnwlege1(n, a, b): """ Compute univariate Guass-Legendre quadrature nodes and weights Parameters ---------- n : int The number of nodes a : int The lower endpoint b : int The upper endpoint Returns ------- nodes : np.ndarray(dtype=float) A...
[ "def", "_qnwlege1", "(", "n", ",", "a", ",", "b", ")", ":", "# import ipdb; ipdb.set_trace()", "maxit", "=", "100", "m", "=", "int", "(", "fix", "(", "(", "n", "+", "1", ")", "/", "2.0", ")", ")", "xm", "=", "0.5", "*", "(", "b", "+", "a", ")...
Compute univariate Guass-Legendre quadrature nodes and weights Parameters ---------- n : int The number of nodes a : int The lower endpoint b : int The upper endpoint Returns ------- nodes : np.ndarray(dtype=float) An n element array of nodes node...
[ "Compute", "univariate", "Guass", "-", "Legendre", "quadrature", "nodes", "and", "weights" ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/quad.py#L733-L802
train
Compute univariate Guass - Legendre quadrature nodes and weights for a given interval.
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/quad.py
_qnwnorm1
def _qnwnorm1(n): """ Compute nodes and weights for quadrature of univariate standard normal distribution Parameters ---------- n : int The number of nodes Returns ------- nodes : np.ndarray(dtype=float) An n element array of nodes nodes : np.ndarray(dtype=floa...
python
def _qnwnorm1(n): """ Compute nodes and weights for quadrature of univariate standard normal distribution Parameters ---------- n : int The number of nodes Returns ------- nodes : np.ndarray(dtype=float) An n element array of nodes nodes : np.ndarray(dtype=floa...
[ "def", "_qnwnorm1", "(", "n", ")", ":", "maxit", "=", "100", "pim4", "=", "1", "/", "np", ".", "pi", "**", "(", "0.25", ")", "m", "=", "int", "(", "fix", "(", "(", "n", "+", "1", ")", "/", "2", ")", ")", "nodes", "=", "np", ".", "zeros", ...
Compute nodes and weights for quadrature of univariate standard normal distribution Parameters ---------- n : int The number of nodes Returns ------- nodes : np.ndarray(dtype=float) An n element array of nodes nodes : np.ndarray(dtype=float) An n element array ...
[ "Compute", "nodes", "and", "weights", "for", "quadrature", "of", "univariate", "standard", "normal", "distribution" ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/quad.py#L805-L880
train
Compute nodes and weights for univariate standard distribution.
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/quad.py
_qnwsimp1
def _qnwsimp1(n, a, b): """ Compute univariate Simpson quadrature nodes and weights Parameters ---------- n : int The number of nodes a : int The lower endpoint b : int The upper endpoint Returns ------- nodes : np.ndarray(dtype=float) An n ele...
python
def _qnwsimp1(n, a, b): """ Compute univariate Simpson quadrature nodes and weights Parameters ---------- n : int The number of nodes a : int The lower endpoint b : int The upper endpoint Returns ------- nodes : np.ndarray(dtype=float) An n ele...
[ "def", "_qnwsimp1", "(", "n", ",", "a", ",", "b", ")", ":", "if", "n", "%", "2", "==", "0", ":", "print", "(", "\"WARNING qnwsimp: n must be an odd integer. Increasing by 1\"", ")", "n", "+=", "1", "nodes", "=", "np", ".", "linspace", "(", "a", ",", "b...
Compute univariate Simpson quadrature nodes and weights Parameters ---------- n : int The number of nodes a : int The lower endpoint b : int The upper endpoint Returns ------- nodes : np.ndarray(dtype=float) An n element array of nodes nodes : np....
[ "Compute", "univariate", "Simpson", "quadrature", "nodes", "and", "weights" ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/quad.py#L883-L928
train
Compute univariate Simpson quadrature nodes and weights
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/quad.py
_qnwtrap1
def _qnwtrap1(n, a, b): """ Compute univariate trapezoid rule quadrature nodes and weights Parameters ---------- n : int The number of nodes a : int The lower endpoint b : int The upper endpoint Returns ------- nodes : np.ndarray(dtype=float) A...
python
def _qnwtrap1(n, a, b): """ Compute univariate trapezoid rule quadrature nodes and weights Parameters ---------- n : int The number of nodes a : int The lower endpoint b : int The upper endpoint Returns ------- nodes : np.ndarray(dtype=float) A...
[ "def", "_qnwtrap1", "(", "n", ",", "a", ",", "b", ")", ":", "if", "n", "<", "1", ":", "raise", "ValueError", "(", "\"n must be at least one\"", ")", "nodes", "=", "np", ".", "linspace", "(", "a", ",", "b", ",", "n", ")", "dx", "=", "nodes", "[", ...
Compute univariate trapezoid rule quadrature nodes and weights Parameters ---------- n : int The number of nodes a : int The lower endpoint b : int The upper endpoint Returns ------- nodes : np.ndarray(dtype=float) An n element array of nodes node...
[ "Compute", "univariate", "trapezoid", "rule", "quadrature", "nodes", "and", "weights" ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/quad.py#L931-L975
train
Compute univariate trapezoid rule quadrature nodes and weights
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/quad.py
_qnwbeta1
def _qnwbeta1(n, a=1.0, b=1.0): """ Computes nodes and weights for quadrature on the beta distribution. Default is a=b=1 which is just a uniform distribution NOTE: For now I am just following compecon; would be much better to find a different way since I don't know what they are doing. Paramet...
python
def _qnwbeta1(n, a=1.0, b=1.0): """ Computes nodes and weights for quadrature on the beta distribution. Default is a=b=1 which is just a uniform distribution NOTE: For now I am just following compecon; would be much better to find a different way since I don't know what they are doing. Paramet...
[ "def", "_qnwbeta1", "(", "n", ",", "a", "=", "1.0", ",", "b", "=", "1.0", ")", ":", "# We subtract one and write a + 1 where we actually want a, and a", "# where we want a - 1", "a", "=", "a", "-", "1", "b", "=", "b", "-", "1", "maxiter", "=", "25", "# Alloc...
Computes nodes and weights for quadrature on the beta distribution. Default is a=b=1 which is just a uniform distribution NOTE: For now I am just following compecon; would be much better to find a different way since I don't know what they are doing. Parameters ---------- n : scalar : int ...
[ "Computes", "nodes", "and", "weights", "for", "quadrature", "on", "the", "beta", "distribution", ".", "Default", "is", "a", "=", "b", "=", "1", "which", "is", "just", "a", "uniform", "distribution" ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/quad.py#L978-L1098
train
This function is used to compute the nodes and weights for a beta distribution.
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/quad.py
_qnwgamma1
def _qnwgamma1(n, a=1.0, b=1.0, tol=3e-14): """ 1d quadrature weights and nodes for Gamma distributed random variable Parameters ---------- n : scalar : int The number of quadrature points a : scalar : float, optional(default=1.0) Shape parameter of the gamma distribution param...
python
def _qnwgamma1(n, a=1.0, b=1.0, tol=3e-14): """ 1d quadrature weights and nodes for Gamma distributed random variable Parameters ---------- n : scalar : int The number of quadrature points a : scalar : float, optional(default=1.0) Shape parameter of the gamma distribution param...
[ "def", "_qnwgamma1", "(", "n", ",", "a", "=", "1.0", ",", "b", "=", "1.0", ",", "tol", "=", "3e-14", ")", ":", "a", "-=", "1", "maxit", "=", "25", "factor", "=", "-", "math", ".", "exp", "(", "gammaln", "(", "a", "+", "n", ")", "-", "gammal...
1d quadrature weights and nodes for Gamma distributed random variable Parameters ---------- n : scalar : int The number of quadrature points a : scalar : float, optional(default=1.0) Shape parameter of the gamma distribution parameter. Must be positive b : scalar : float, optional...
[ "1d", "quadrature", "weights", "and", "nodes", "for", "Gamma", "distributed", "random", "variable" ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/quad.py#L1101-L1181
train
Function to create a newton random variable from a gamma distribution.
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/vertex_enumeration.py
vertex_enumeration_gen
def vertex_enumeration_gen(g, qhull_options=None): """ Generator version of `vertex_enumeration`. Parameters ---------- g : NormalFormGame NormalFormGame instance with 2 players. qhull_options : str, optional(default=None) Options to pass to `scipy.spatial.ConvexHull`. See the ...
python
def vertex_enumeration_gen(g, qhull_options=None): """ Generator version of `vertex_enumeration`. Parameters ---------- g : NormalFormGame NormalFormGame instance with 2 players. qhull_options : str, optional(default=None) Options to pass to `scipy.spatial.ConvexHull`. See the ...
[ "def", "vertex_enumeration_gen", "(", "g", ",", "qhull_options", "=", "None", ")", ":", "try", ":", "N", "=", "g", ".", "N", "except", "AttributeError", ":", "raise", "TypeError", "(", "'input must be a 2-player NormalFormGame'", ")", "if", "N", "!=", "2", "...
Generator version of `vertex_enumeration`. Parameters ---------- g : NormalFormGame NormalFormGame instance with 2 players. qhull_options : str, optional(default=None) Options to pass to `scipy.spatial.ConvexHull`. See the `Qhull manual <http://www.qhull.org>`_ for details. ...
[ "Generator", "version", "of", "vertex_enumeration", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/game_theory/vertex_enumeration.py#L48-L84
train
Generate a vertex_enumeration generator for a NormalFormGame instance.
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/vertex_enumeration.py
_vertex_enumeration_gen
def _vertex_enumeration_gen(labelings_bits_tup, equations_tup, trans_recips): """ Main body of `vertex_enumeration_gen`. Parameters ---------- labelings_bits_tup : tuple(ndarray(np.uint64, ndim=1)) Tuple of ndarrays of integers representing labelings of the vertices of the best resp...
python
def _vertex_enumeration_gen(labelings_bits_tup, equations_tup, trans_recips): """ Main body of `vertex_enumeration_gen`. Parameters ---------- labelings_bits_tup : tuple(ndarray(np.uint64, ndim=1)) Tuple of ndarrays of integers representing labelings of the vertices of the best resp...
[ "def", "_vertex_enumeration_gen", "(", "labelings_bits_tup", ",", "equations_tup", ",", "trans_recips", ")", ":", "m", ",", "n", "=", "equations_tup", "[", "0", "]", ".", "shape", "[", "1", "]", "-", "1", ",", "equations_tup", "[", "1", "]", ".", "shape"...
Main body of `vertex_enumeration_gen`. Parameters ---------- labelings_bits_tup : tuple(ndarray(np.uint64, ndim=1)) Tuple of ndarrays of integers representing labelings of the vertices of the best response polytopes. equations_tup : tuple(ndarray(float, ndim=2)) Tuple of ndarra...
[ "Main", "body", "of", "vertex_enumeration_gen", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/game_theory/vertex_enumeration.py#L88-L123
train
Generator for the vertex_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/vertex_enumeration.py
_ints_arr_to_bits
def _ints_arr_to_bits(ints_arr, out): """ Convert an array of integers representing the set bits into the corresponding integer. Compiled as a ufunc by Numba's `@guvectorize`: if the input is a 2-dim array with shape[0]=K, the function returns a 1-dim array of K converted integers. Paramet...
python
def _ints_arr_to_bits(ints_arr, out): """ Convert an array of integers representing the set bits into the corresponding integer. Compiled as a ufunc by Numba's `@guvectorize`: if the input is a 2-dim array with shape[0]=K, the function returns a 1-dim array of K converted integers. Paramet...
[ "def", "_ints_arr_to_bits", "(", "ints_arr", ",", "out", ")", ":", "m", "=", "ints_arr", ".", "shape", "[", "0", "]", "out", "[", "0", "]", "=", "0", "for", "i", "in", "range", "(", "m", ")", ":", "out", "[", "0", "]", "|=", "np", ".", "uint6...
Convert an array of integers representing the set bits into the corresponding integer. Compiled as a ufunc by Numba's `@guvectorize`: if the input is a 2-dim array with shape[0]=K, the function returns a 1-dim array of K converted integers. Parameters ---------- ints_arr : ndarray(int32, n...
[ "Convert", "an", "array", "of", "integers", "representing", "the", "set", "bits", "into", "the", "corresponding", "integer", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/game_theory/vertex_enumeration.py#L258-L290
train
Convert an array of integers representing the set bits into the corresponding integer.
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/vertex_enumeration.py
_get_mixed_actions
def _get_mixed_actions(labeling_bits, equation_tup, trans_recips): """ From a labeling for player 0, a tuple of hyperplane equations of the polar polytopes, and a tuple of the reciprocals of the translations, return a tuple of the corresponding, normalized mixed actions. Parameters ---------- ...
python
def _get_mixed_actions(labeling_bits, equation_tup, trans_recips): """ From a labeling for player 0, a tuple of hyperplane equations of the polar polytopes, and a tuple of the reciprocals of the translations, return a tuple of the corresponding, normalized mixed actions. Parameters ---------- ...
[ "def", "_get_mixed_actions", "(", "labeling_bits", ",", "equation_tup", ",", "trans_recips", ")", ":", "m", ",", "n", "=", "equation_tup", "[", "0", "]", ".", "shape", "[", "0", "]", "-", "1", ",", "equation_tup", "[", "1", "]", ".", "shape", "[", "0...
From a labeling for player 0, a tuple of hyperplane equations of the polar polytopes, and a tuple of the reciprocals of the translations, return a tuple of the corresponding, normalized mixed actions. Parameters ---------- labeling_bits : scalar(np.uint64) Integer with set bits representing...
[ "From", "a", "labeling", "for", "player", "0", "a", "tuple", "of", "hyperplane", "equations", "of", "the", "polar", "polytopes", "and", "a", "tuple", "of", "the", "reciprocals", "of", "the", "translations", "return", "a", "tuple", "of", "the", "corresponding...
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/game_theory/vertex_enumeration.py#L294-L335
train
This function returns a tuple of mixed actions for the current language.
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/ce_util.py
gridmake
def gridmake(*arrays): """ Expands one or more vectors (or matrices) into a matrix where rows span the cartesian product of combinations of the input arrays. Each column of the input arrays will correspond to one column of the output matrix. Parameters ---------- *arrays : tuple/list of np....
python
def gridmake(*arrays): """ Expands one or more vectors (or matrices) into a matrix where rows span the cartesian product of combinations of the input arrays. Each column of the input arrays will correspond to one column of the output matrix. Parameters ---------- *arrays : tuple/list of np....
[ "def", "gridmake", "(", "*", "arrays", ")", ":", "if", "all", "(", "[", "i", ".", "ndim", "==", "1", "for", "i", "in", "arrays", "]", ")", ":", "d", "=", "len", "(", "arrays", ")", "if", "d", "==", "2", ":", "out", "=", "_gridmake2", "(", "...
Expands one or more vectors (or matrices) into a matrix where rows span the cartesian product of combinations of the input arrays. Each column of the input arrays will correspond to one column of the output matrix. Parameters ---------- *arrays : tuple/list of np.ndarray Tuple/list of...
[ "Expands", "one", "or", "more", "vectors", "(", "or", "matrices", ")", "into", "a", "matrix", "where", "rows", "span", "the", "cartesian", "product", "of", "combinations", "of", "the", "input", "arrays", ".", "Each", "column", "of", "the", "input", "arrays...
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/ce_util.py#L44-L82
train
Returns a matrix where rows span the cartesian product of combinations of the input arrays.
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/ce_util.py
_gridmake2
def _gridmake2(x1, x2): """ Expands two vectors (or matrices) into a matrix where rows span the cartesian product of combinations of the input arrays. Each column of the input arrays will correspond to one column of the output matrix. Parameters ---------- x1 : np.ndarray First vec...
python
def _gridmake2(x1, x2): """ Expands two vectors (or matrices) into a matrix where rows span the cartesian product of combinations of the input arrays. Each column of the input arrays will correspond to one column of the output matrix. Parameters ---------- x1 : np.ndarray First vec...
[ "def", "_gridmake2", "(", "x1", ",", "x2", ")", ":", "if", "x1", ".", "ndim", "==", "1", "and", "x2", ".", "ndim", "==", "1", ":", "return", "np", ".", "column_stack", "(", "[", "np", ".", "tile", "(", "x1", ",", "x2", ".", "shape", "[", "0",...
Expands two vectors (or matrices) into a matrix where rows span the cartesian product of combinations of the input arrays. Each column of the input arrays will correspond to one column of the output matrix. Parameters ---------- x1 : np.ndarray First vector to be expanded. x2 : np.nda...
[ "Expands", "two", "vectors", "(", "or", "matrices", ")", "into", "a", "matrix", "where", "rows", "span", "the", "cartesian", "product", "of", "combinations", "of", "the", "input", "arrays", ".", "Each", "column", "of", "the", "input", "arrays", "will", "co...
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/ce_util.py#L85-L123
train
This function is used to expand two vectors or matrices into a matrix where rows span the cartesian product of combinations of x1 and x2.
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/random/utilities.py
probvec
def probvec(m, k, random_state=None, parallel=True): """ Return m randomly sampled probability vectors of dimension k. Parameters ---------- m : scalar(int) Number of probability vectors. k : scalar(int) Dimension of each probability vectors. random_state : int or np.rando...
python
def probvec(m, k, random_state=None, parallel=True): """ Return m randomly sampled probability vectors of dimension k. Parameters ---------- m : scalar(int) Number of probability vectors. k : scalar(int) Dimension of each probability vectors. random_state : int or np.rando...
[ "def", "probvec", "(", "m", ",", "k", ",", "random_state", "=", "None", ",", "parallel", "=", "True", ")", ":", "if", "k", "==", "1", ":", "return", "np", ".", "ones", "(", "(", "m", ",", "k", ")", ")", "# if k >= 2", "random_state", "=", "check_...
Return m randomly sampled probability vectors of dimension k. Parameters ---------- m : scalar(int) Number of probability vectors. k : scalar(int) Dimension of each probability vectors. random_state : int or np.random.RandomState, optional Random seed (integer) or np.rando...
[ "Return", "m", "randomly", "sampled", "probability", "vectors", "of", "dimension", "k", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/random/utilities.py#L14-L63
train
Returns m randomly sampled probability vectors of dimension k.
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/random/utilities.py
_probvec
def _probvec(r, out): """ Fill `out` with randomly sampled probability vectors as rows. To be complied as a ufunc by guvectorize of Numba. The inputs must have the same shape except the last axis; the length of the last axis of `r` must be that of `out` minus 1, i.e., if out.shape[-1] is k, the...
python
def _probvec(r, out): """ Fill `out` with randomly sampled probability vectors as rows. To be complied as a ufunc by guvectorize of Numba. The inputs must have the same shape except the last axis; the length of the last axis of `r` must be that of `out` minus 1, i.e., if out.shape[-1] is k, the...
[ "def", "_probvec", "(", "r", ",", "out", ")", ":", "n", "=", "r", ".", "shape", "[", "0", "]", "r", ".", "sort", "(", ")", "out", "[", "0", "]", "=", "r", "[", "0", "]", "for", "i", "in", "range", "(", "1", ",", "n", ")", ":", "out", ...
Fill `out` with randomly sampled probability vectors as rows. To be complied as a ufunc by guvectorize of Numba. The inputs must have the same shape except the last axis; the length of the last axis of `r` must be that of `out` minus 1, i.e., if out.shape[-1] is k, then r.shape[-1] must be k-1. Pa...
[ "Fill", "out", "with", "randomly", "sampled", "probability", "vectors", "as", "rows", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/random/utilities.py#L66-L89
train
Fill out with randomly sampled probability vectors as rows.
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/random/utilities.py
sample_without_replacement
def sample_without_replacement(n, k, num_trials=None, random_state=None): """ Randomly choose k integers without replacement from 0, ..., n-1. Parameters ---------- n : scalar(int) Number of integers, 0, ..., n-1, to sample from. k : scalar(int) Number of integers to sample. ...
python
def sample_without_replacement(n, k, num_trials=None, random_state=None): """ Randomly choose k integers without replacement from 0, ..., n-1. Parameters ---------- n : scalar(int) Number of integers, 0, ..., n-1, to sample from. k : scalar(int) Number of integers to sample. ...
[ "def", "sample_without_replacement", "(", "n", ",", "k", ",", "num_trials", "=", "None", ",", "random_state", "=", "None", ")", ":", "if", "n", "<=", "0", ":", "raise", "ValueError", "(", "'n must be greater than 0'", ")", "if", "k", ">", "n", ":", "rais...
Randomly choose k integers without replacement from 0, ..., n-1. Parameters ---------- n : scalar(int) Number of integers, 0, ..., n-1, to sample from. k : scalar(int) Number of integers to sample. num_trials : scalar(int), optional(default=None) Number of trials. ran...
[ "Randomly", "choose", "k", "integers", "without", "replacement", "from", "0", "...", "n", "-", "1", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/random/utilities.py#L101-L152
train
Randomly choose k integers without replacement from 0... n - 1.
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/random/utilities.py
_sample_without_replacement
def _sample_without_replacement(n, r, out): """ Main body of `sample_without_replacement`. To be complied as a ufunc by guvectorize of Numba. """ k = r.shape[0] # Logic taken from random.sample in the standard library pool = np.arange(n) for j in range(k): idx = int(np.floor(r[...
python
def _sample_without_replacement(n, r, out): """ Main body of `sample_without_replacement`. To be complied as a ufunc by guvectorize of Numba. """ k = r.shape[0] # Logic taken from random.sample in the standard library pool = np.arange(n) for j in range(k): idx = int(np.floor(r[...
[ "def", "_sample_without_replacement", "(", "n", ",", "r", ",", "out", ")", ":", "k", "=", "r", ".", "shape", "[", "0", "]", "# Logic taken from random.sample in the standard library", "pool", "=", "np", ".", "arange", "(", "n", ")", "for", "j", "in", "rang...
Main body of `sample_without_replacement`. To be complied as a ufunc by guvectorize of Numba.
[ "Main", "body", "of", "sample_without_replacement", ".", "To", "be", "complied", "as", "a", "ufunc", "by", "guvectorize", "of", "Numba", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/random/utilities.py#L156-L169
train
Sample n random elements from the Numba random variates.
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/random/utilities.py
draw
def draw(cdf, size=None): """ Generate a random sample according to the cumulative distribution given by `cdf`. Jit-complied by Numba in nopython mode. Parameters ---------- cdf : array_like(float, ndim=1) Array containing the cumulative distribution. size : scalar(int), optional(d...
python
def draw(cdf, size=None): """ Generate a random sample according to the cumulative distribution given by `cdf`. Jit-complied by Numba in nopython mode. Parameters ---------- cdf : array_like(float, ndim=1) Array containing the cumulative distribution. size : scalar(int), optional(d...
[ "def", "draw", "(", "cdf", ",", "size", "=", "None", ")", ":", "if", "isinstance", "(", "size", ",", "types", ".", "Integer", ")", ":", "def", "draw_impl", "(", "cdf", ",", "size", ")", ":", "rs", "=", "np", ".", "random", ".", "random_sample", "...
Generate a random sample according to the cumulative distribution given by `cdf`. Jit-complied by Numba in nopython mode. Parameters ---------- cdf : array_like(float, ndim=1) Array containing the cumulative distribution. size : scalar(int), optional(default=None) Size of the sampl...
[ "Generate", "a", "random", "sample", "according", "to", "the", "cumulative", "distribution", "given", "by", "cdf", ".", "Jit", "-", "complied", "by", "Numba", "in", "nopython", "mode", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/random/utilities.py#L173-L212
train
Generates a random sample according to the cumulative distribution 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...
QuantEcon/QuantEcon.py
quantecon/gridtools.py
cartesian
def cartesian(nodes, order='C'): ''' Cartesian product of a list of arrays Parameters ---------- nodes : list(array_like(ndim=1)) order : str, optional(default='C') ('C' or 'F') order in which the product is enumerated Returns ------- out : ndarray(ndim=2) each lin...
python
def cartesian(nodes, order='C'): ''' Cartesian product of a list of arrays Parameters ---------- nodes : list(array_like(ndim=1)) order : str, optional(default='C') ('C' or 'F') order in which the product is enumerated Returns ------- out : ndarray(ndim=2) each lin...
[ "def", "cartesian", "(", "nodes", ",", "order", "=", "'C'", ")", ":", "nodes", "=", "[", "np", ".", "array", "(", "e", ")", "for", "e", "in", "nodes", "]", "shapes", "=", "[", "e", ".", "shape", "[", "0", "]", "for", "e", "in", "nodes", "]", ...
Cartesian product of a list of arrays Parameters ---------- nodes : list(array_like(ndim=1)) order : str, optional(default='C') ('C' or 'F') order in which the product is enumerated Returns ------- out : ndarray(ndim=2) each line corresponds to one point of the product spa...
[ "Cartesian", "product", "of", "a", "list", "of", "arrays" ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/gridtools.py#L13-L51
train
Returns the cartesian product of a list of arrays
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/gridtools.py
mlinspace
def mlinspace(a, b, nums, order='C'): ''' Constructs a regular cartesian grid Parameters ---------- a : array_like(ndim=1) lower bounds in each dimension b : array_like(ndim=1) upper bounds in each dimension nums : array_like(ndim=1) number of nodes along each dime...
python
def mlinspace(a, b, nums, order='C'): ''' Constructs a regular cartesian grid Parameters ---------- a : array_like(ndim=1) lower bounds in each dimension b : array_like(ndim=1) upper bounds in each dimension nums : array_like(ndim=1) number of nodes along each dime...
[ "def", "mlinspace", "(", "a", ",", "b", ",", "nums", ",", "order", "=", "'C'", ")", ":", "a", "=", "np", ".", "array", "(", "a", ",", "dtype", "=", "'float64'", ")", "b", "=", "np", ".", "array", "(", "b", ",", "dtype", "=", "'float64'", ")",...
Constructs a regular cartesian grid Parameters ---------- a : array_like(ndim=1) lower bounds in each dimension b : array_like(ndim=1) upper bounds in each dimension nums : array_like(ndim=1) number of nodes along each dimension order : str, optional(default='C') ...
[ "Constructs", "a", "regular", "cartesian", "grid" ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/gridtools.py#L54-L83
train
Returns a regular cartesian grid of the given numbers
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/gridtools.py
_repeat_1d
def _repeat_1d(x, K, out): ''' Repeats each element of a vector many times and repeats the whole result many times Parameters ---------- x : ndarray(ndim=1) vector to be repeated K : scalar(int) number of times each element of x is repeated (inner iterations) out : nda...
python
def _repeat_1d(x, K, out): ''' Repeats each element of a vector many times and repeats the whole result many times Parameters ---------- x : ndarray(ndim=1) vector to be repeated K : scalar(int) number of times each element of x is repeated (inner iterations) out : nda...
[ "def", "_repeat_1d", "(", "x", ",", "K", ",", "out", ")", ":", "N", "=", "x", ".", "shape", "[", "0", "]", "L", "=", "out", ".", "shape", "[", "0", "]", "//", "(", "K", "*", "N", ")", "# number of outer iterations", "# K # numb...
Repeats each element of a vector many times and repeats the whole result many times Parameters ---------- x : ndarray(ndim=1) vector to be repeated K : scalar(int) number of times each element of x is repeated (inner iterations) out : ndarray(ndim=1) placeholder for th...
[ "Repeats", "each", "element", "of", "a", "vector", "many", "times", "and", "repeats", "the", "whole", "result", "many", "times" ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/gridtools.py#L87-L121
train
Repeats each element of a vector many times and repeats the whole result many times
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/gridtools.py
simplex_grid
def simplex_grid(m, n): r""" Construct an array consisting of the integer points in the (m-1)-dimensional simplex :math:`\{x \mid x_0 + \cdots + x_{m-1} = n \}`, or equivalently, the m-part compositions of n, which are listed in lexicographic order. The total number of the points (hence the leng...
python
def simplex_grid(m, n): r""" Construct an array consisting of the integer points in the (m-1)-dimensional simplex :math:`\{x \mid x_0 + \cdots + x_{m-1} = n \}`, or equivalently, the m-part compositions of n, which are listed in lexicographic order. The total number of the points (hence the leng...
[ "def", "simplex_grid", "(", "m", ",", "n", ")", ":", "L", "=", "num_compositions_jit", "(", "m", ",", "n", ")", "if", "L", "==", "0", ":", "# Overflow occured", "raise", "ValueError", "(", "_msg_max_size_exceeded", ")", "out", "=", "np", ".", "empty", ...
r""" Construct an array consisting of the integer points in the (m-1)-dimensional simplex :math:`\{x \mid x_0 + \cdots + x_{m-1} = n \}`, or equivalently, the m-part compositions of n, which are listed in lexicographic order. The total number of the points (hence the length of the output array) is L...
[ "r", "Construct", "an", "array", "consisting", "of", "the", "integer", "points", "in", "the", "(", "m", "-", "1", ")", "-", "dimensional", "simplex", ":", "math", ":", "\\", "{", "x", "\\", "mid", "x_0", "+", "\\", "cdots", "+", "x_", "{", "m", "...
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/gridtools.py#L128-L226
train
r Constructs a simplex grid of the n - dimensional m - part compositions of the n - dimensional simplex.
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/gridtools.py
simplex_index
def simplex_index(x, m, n): r""" Return the index of the point x in the lexicographic order of the integer points of the (m-1)-dimensional simplex :math:`\{x \mid x_0 + \cdots + x_{m-1} = n\}`. Parameters ---------- x : array_like(int, ndim=1) Integer point in the simplex, i.e., an ...
python
def simplex_index(x, m, n): r""" Return the index of the point x in the lexicographic order of the integer points of the (m-1)-dimensional simplex :math:`\{x \mid x_0 + \cdots + x_{m-1} = n\}`. Parameters ---------- x : array_like(int, ndim=1) Integer point in the simplex, i.e., an ...
[ "def", "simplex_index", "(", "x", ",", "m", ",", "n", ")", ":", "if", "m", "==", "1", ":", "return", "0", "decumsum", "=", "np", ".", "cumsum", "(", "x", "[", "-", "1", ":", "0", ":", "-", "1", "]", ")", "[", ":", ":", "-", "1", "]", "i...
r""" Return the index of the point x in the lexicographic order of the integer points of the (m-1)-dimensional simplex :math:`\{x \mid x_0 + \cdots + x_{m-1} = n\}`. Parameters ---------- x : array_like(int, ndim=1) Integer point in the simplex, i.e., an array of m nonnegative i...
[ "r", "Return", "the", "index", "of", "the", "point", "x", "in", "the", "lexicographic", "order", "of", "the", "integer", "points", "of", "the", "(", "m", "-", "1", ")", "-", "dimensional", "simplex", ":", "math", ":", "\\", "{", "x", "\\", "mid", "...
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/gridtools.py#L229-L263
train
r Returns the index of the point x in the lexicographic order of the simplex.
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/gridtools.py
num_compositions
def num_compositions(m, n): """ The total number of m-part compositions of n, which is equal to (n+m-1) choose (m-1). Parameters ---------- m : scalar(int) Number of parts of composition. n : scalar(int) Integer to decompose. Returns ------- scalar(int) ...
python
def num_compositions(m, n): """ The total number of m-part compositions of n, which is equal to (n+m-1) choose (m-1). Parameters ---------- m : scalar(int) Number of parts of composition. n : scalar(int) Integer to decompose. Returns ------- scalar(int) ...
[ "def", "num_compositions", "(", "m", ",", "n", ")", ":", "# docs.scipy.org/doc/scipy/reference/generated/scipy.special.comb.html", "return", "scipy", ".", "special", ".", "comb", "(", "n", "+", "m", "-", "1", ",", "m", "-", "1", ",", "exact", "=", "True", ")...
The total number of m-part compositions of n, which is equal to (n+m-1) choose (m-1). Parameters ---------- m : scalar(int) Number of parts of composition. n : scalar(int) Integer to decompose. Returns ------- scalar(int) Total number of m-part compositions of ...
[ "The", "total", "number", "of", "m", "-", "part", "compositions", "of", "n", "which", "is", "equal", "to", "(", "n", "+", "m", "-", "1", ")", "choose", "(", "m", "-", "1", ")", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/gridtools.py#L266-L286
train
Returns the total number of m - part compositions of n.
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/arma.py
ARMA.set_params
def set_params(self): r""" Internally, scipy.signal works with systems of the form .. math:: ar_{poly}(L) X_t = ma_{poly}(L) \epsilon_t where L is the lag operator. To match this, we set .. math:: ar_{poly} = (1, -\phi_1, -\phi_2,..., -\phi_p) ...
python
def set_params(self): r""" Internally, scipy.signal works with systems of the form .. math:: ar_{poly}(L) X_t = ma_{poly}(L) \epsilon_t where L is the lag operator. To match this, we set .. math:: ar_{poly} = (1, -\phi_1, -\phi_2,..., -\phi_p) ...
[ "def", "set_params", "(", "self", ")", ":", "# === set up ma_poly === #", "ma_poly", "=", "np", ".", "asarray", "(", "self", ".", "_theta", ")", "self", ".", "ma_poly", "=", "np", ".", "insert", "(", "ma_poly", ",", "0", ",", "1", ")", "# The array (1, t...
r""" Internally, scipy.signal works with systems of the form .. math:: ar_{poly}(L) X_t = ma_{poly}(L) \epsilon_t where L is the lag operator. To match this, we set .. math:: ar_{poly} = (1, -\phi_1, -\phi_2,..., -\phi_p) ma_{poly} = (1, \theta_1...
[ "r", "Internally", "scipy", ".", "signal", "works", "with", "systems", "of", "the", "form" ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/arma.py#L119-L153
train
r Sets the parameters of the object to match the parameters of the 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...
QuantEcon/QuantEcon.py
quantecon/arma.py
ARMA.impulse_response
def impulse_response(self, impulse_length=30): """ Get the impulse response corresponding to our model. Returns ------- psi : array_like(float) psi[j] is the response at lag j of the impulse response. We take psi[0] as unity. """ from sci...
python
def impulse_response(self, impulse_length=30): """ Get the impulse response corresponding to our model. Returns ------- psi : array_like(float) psi[j] is the response at lag j of the impulse response. We take psi[0] as unity. """ from sci...
[ "def", "impulse_response", "(", "self", ",", "impulse_length", "=", "30", ")", ":", "from", "scipy", ".", "signal", "import", "dimpulse", "sys", "=", "self", ".", "ma_poly", ",", "self", ".", "ar_poly", ",", "1", "times", ",", "psi", "=", "dimpulse", "...
Get the impulse response corresponding to our model. Returns ------- psi : array_like(float) psi[j] is the response at lag j of the impulse response. We take psi[0] as unity.
[ "Get", "the", "impulse", "response", "corresponding", "to", "our", "model", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/arma.py#L155-L171
train
Get the impulse response corresponding to our model.
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/arma.py
ARMA.spectral_density
def spectral_density(self, two_pi=True, res=1200): r""" Compute the spectral density function. The spectral density is the discrete time Fourier transform of the autocovariance function. In particular, .. math:: f(w) = \sum_k \gamma(k) \exp(-ikw) where ga...
python
def spectral_density(self, two_pi=True, res=1200): r""" Compute the spectral density function. The spectral density is the discrete time Fourier transform of the autocovariance function. In particular, .. math:: f(w) = \sum_k \gamma(k) \exp(-ikw) where ga...
[ "def", "spectral_density", "(", "self", ",", "two_pi", "=", "True", ",", "res", "=", "1200", ")", ":", "from", "scipy", ".", "signal", "import", "freqz", "w", ",", "h", "=", "freqz", "(", "self", ".", "ma_poly", ",", "self", ".", "ar_poly", ",", "w...
r""" Compute the spectral density function. The spectral density is the discrete time Fourier transform of the autocovariance function. In particular, .. math:: f(w) = \sum_k \gamma(k) \exp(-ikw) where gamma is the autocovariance function and the sum is over ...
[ "r", "Compute", "the", "spectral", "density", "function", ".", "The", "spectral", "density", "is", "the", "discrete", "time", "Fourier", "transform", "of", "the", "autocovariance", "function", ".", "In", "particular" ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/arma.py#L173-L211
train
r Compute the spectral density of the entry in the set of unique entries.
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/arma.py
ARMA.autocovariance
def autocovariance(self, num_autocov=16): """ Compute the autocovariance function from the ARMA parameters over the integers range(num_autocov) using the spectral density and the inverse Fourier transform. Parameters ---------- num_autocov : scalar(int), optional...
python
def autocovariance(self, num_autocov=16): """ Compute the autocovariance function from the ARMA parameters over the integers range(num_autocov) using the spectral density and the inverse Fourier transform. Parameters ---------- num_autocov : scalar(int), optional...
[ "def", "autocovariance", "(", "self", ",", "num_autocov", "=", "16", ")", ":", "spect", "=", "self", ".", "spectral_density", "(", ")", "[", "1", "]", "acov", "=", "np", ".", "fft", ".", "ifft", "(", "spect", ")", ".", "real", "# num_autocov should be ...
Compute the autocovariance function from the ARMA parameters over the integers range(num_autocov) using the spectral density and the inverse Fourier transform. Parameters ---------- num_autocov : scalar(int), optional(default=16) The number of autocovariances to calc...
[ "Compute", "the", "autocovariance", "function", "from", "the", "ARMA", "parameters", "over", "the", "integers", "range", "(", "num_autocov", ")", "using", "the", "spectral", "density", "and", "the", "inverse", "Fourier", "transform", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/arma.py#L213-L229
train
Calculates the autocovariance function from the ARMA parameters and returns it.
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/arma.py
ARMA.simulation
def simulation(self, ts_length=90, random_state=None): """ Compute a simulated sample path assuming Gaussian shocks. Parameters ---------- ts_length : scalar(int), optional(default=90) Number of periods to simulate for random_state : int or np.random.RandomS...
python
def simulation(self, ts_length=90, random_state=None): """ Compute a simulated sample path assuming Gaussian shocks. Parameters ---------- ts_length : scalar(int), optional(default=90) Number of periods to simulate for random_state : int or np.random.RandomS...
[ "def", "simulation", "(", "self", ",", "ts_length", "=", "90", ",", "random_state", "=", "None", ")", ":", "from", "scipy", ".", "signal", "import", "dlsim", "random_state", "=", "check_random_state", "(", "random_state", ")", "sys", "=", "self", ".", "ma_...
Compute a simulated sample path assuming Gaussian shocks. Parameters ---------- ts_length : scalar(int), optional(default=90) Number of periods to simulate for random_state : int or np.random.RandomState, optional Random seed (integer) or np.random.RandomState i...
[ "Compute", "a", "simulated", "sample", "path", "assuming", "Gaussian", "shocks", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/arma.py#L231-L259
train
Compute a simulated sample path assuming Gaussian shocks.
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/dle.py
DLE.compute_steadystate
def compute_steadystate(self, nnc=2): """ Computes the non-stochastic steady-state of the economy. Parameters ---------- nnc : array_like(float) nnc is the location of the constant in the state vector x_t """ zx = np.eye(self.A0.shape[0])-self.A0 ...
python
def compute_steadystate(self, nnc=2): """ Computes the non-stochastic steady-state of the economy. Parameters ---------- nnc : array_like(float) nnc is the location of the constant in the state vector x_t """ zx = np.eye(self.A0.shape[0])-self.A0 ...
[ "def", "compute_steadystate", "(", "self", ",", "nnc", "=", "2", ")", ":", "zx", "=", "np", ".", "eye", "(", "self", ".", "A0", ".", "shape", "[", "0", "]", ")", "-", "self", ".", "A0", "self", ".", "zz", "=", "nullspace", "(", "zx", ")", "se...
Computes the non-stochastic steady-state of the economy. Parameters ---------- nnc : array_like(float) nnc is the location of the constant in the state vector x_t
[ "Computes", "the", "non", "-", "stochastic", "steady", "-", "state", "of", "the", "economy", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/dle.py#L159-L178
train
Computes the non - stochastic steady - state of the economy.
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/dle.py
DLE.compute_sequence
def compute_sequence(self, x0, ts_length=None, Pay=None): """ Simulate quantities and prices for the economy Parameters ---------- x0 : array_like(float) The initial state ts_length : scalar(int) Length of the simulation Pay : array_like...
python
def compute_sequence(self, x0, ts_length=None, Pay=None): """ Simulate quantities and prices for the economy Parameters ---------- x0 : array_like(float) The initial state ts_length : scalar(int) Length of the simulation Pay : array_like...
[ "def", "compute_sequence", "(", "self", ",", "x0", ",", "ts_length", "=", "None", ",", "Pay", "=", "None", ")", ":", "lq", "=", "LQ", "(", "self", ".", "Q", ",", "self", ".", "R", ",", "self", ".", "A", ",", "self", ".", "B", ",", "self", "."...
Simulate quantities and prices for the economy Parameters ---------- x0 : array_like(float) The initial state ts_length : scalar(int) Length of the simulation Pay : array_like(float) Vector to price an asset whose payout is Pay*xt
[ "Simulate", "quantities", "and", "prices", "for", "the", "economy" ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/dle.py#L180-L249
train
Computes the quantities and prices for the economy.
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/dle.py
DLE.irf
def irf(self, ts_length=100, shock=None): """ Create Impulse Response Functions Parameters ---------- ts_length : scalar(int) Number of periods to calculate IRF Shock : array_like(float) Vector of shocks to calculate IRF to. Default is first ele...
python
def irf(self, ts_length=100, shock=None): """ Create Impulse Response Functions Parameters ---------- ts_length : scalar(int) Number of periods to calculate IRF Shock : array_like(float) Vector of shocks to calculate IRF to. Default is first ele...
[ "def", "irf", "(", "self", ",", "ts_length", "=", "100", ",", "shock", "=", "None", ")", ":", "if", "type", "(", "shock", ")", "!=", "np", ".", "ndarray", ":", "# Default is to select first element of w", "shock", "=", "np", ".", "vstack", "(", "(", "n...
Create Impulse Response Functions Parameters ---------- ts_length : scalar(int) Number of periods to calculate IRF Shock : array_like(float) Vector of shocks to calculate IRF to. Default is first element of w
[ "Create", "Impulse", "Response", "Functions" ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/dle.py#L251-L297
train
Calculates the IRF of the current set of IAFs for the current set of periods and shocks.
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/dle.py
DLE.canonical
def canonical(self): """ Compute canonical preference representation Uses auxiliary problem of 9.4.2, with the preference shock process reintroduced Calculates pihat, llambdahat and ubhat for the equivalent canonical household technology """ Ac1 = np.hstack((self.deltah,...
python
def canonical(self): """ Compute canonical preference representation Uses auxiliary problem of 9.4.2, with the preference shock process reintroduced Calculates pihat, llambdahat and ubhat for the equivalent canonical household technology """ Ac1 = np.hstack((self.deltah,...
[ "def", "canonical", "(", "self", ")", ":", "Ac1", "=", "np", ".", "hstack", "(", "(", "self", ".", "deltah", ",", "np", ".", "zeros", "(", "(", "self", ".", "nh", ",", "self", ".", "nz", ")", ")", ")", ")", "Ac2", "=", "np", ".", "hstack", ...
Compute canonical preference representation Uses auxiliary problem of 9.4.2, with the preference shock process reintroduced Calculates pihat, llambdahat and ubhat for the equivalent canonical household technology
[ "Compute", "canonical", "preference", "representation", "Uses", "auxiliary", "problem", "of", "9", ".", "4", ".", "2", "with", "the", "preference", "shock", "process", "reintroduced", "Calculates", "pihat", "llambdahat", "and", "ubhat", "for", "the", "equivalent",...
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/dle.py#L299-L330
train
Compute the canonical preference representation of the current household technology.
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/kalman.py
Kalman.whitener_lss
def whitener_lss(self): r""" This function takes the linear state space system that is an input to the Kalman class and it converts that system to the time-invariant whitener represenation given by .. math:: \tilde{x}_{t+1}^* = \tilde{A} \tilde{x} + \tilde{C...
python
def whitener_lss(self): r""" This function takes the linear state space system that is an input to the Kalman class and it converts that system to the time-invariant whitener represenation given by .. math:: \tilde{x}_{t+1}^* = \tilde{A} \tilde{x} + \tilde{C...
[ "def", "whitener_lss", "(", "self", ")", ":", "K", "=", "self", ".", "K_infinity", "# Get the matrix sizes", "n", ",", "k", ",", "m", ",", "l", "=", "self", ".", "ss", ".", "n", ",", "self", ".", "ss", ".", "k", ",", "self", ".", "ss", ".", "m"...
r""" This function takes the linear state space system that is an input to the Kalman class and it converts that system to the time-invariant whitener represenation given by .. math:: \tilde{x}_{t+1}^* = \tilde{A} \tilde{x} + \tilde{C} v a = \tilde{G} \t...
[ "r", "This", "function", "takes", "the", "linear", "state", "space", "system", "that", "is", "an", "input", "to", "the", "Kalman", "class", "and", "it", "converts", "that", "system", "to", "the", "time", "-", "invariant", "whitener", "represenation", "given"...
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/kalman.py#L105-L178
train
r This function converts the linear state space system that represents the Kalman instance and returns the linear state space system that represents the Kalman instance.
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/kalman.py
Kalman.prior_to_filtered
def prior_to_filtered(self, y): r""" Updates the moments (x_hat, Sigma) of the time t prior to the time t filtering distribution, using current measurement :math:`y_t`. The updates are according to .. math:: \hat{x}^F = \hat{x} + \Sigma G' (G \Sigma G' + R)^{-1} ...
python
def prior_to_filtered(self, y): r""" Updates the moments (x_hat, Sigma) of the time t prior to the time t filtering distribution, using current measurement :math:`y_t`. The updates are according to .. math:: \hat{x}^F = \hat{x} + \Sigma G' (G \Sigma G' + R)^{-1} ...
[ "def", "prior_to_filtered", "(", "self", ",", "y", ")", ":", "# === simplify notation === #", "G", ",", "H", "=", "self", ".", "ss", ".", "G", ",", "self", ".", "ss", ".", "H", "R", "=", "np", ".", "dot", "(", "H", ",", "H", ".", "T", ")", "# =...
r""" Updates the moments (x_hat, Sigma) of the time t prior to the time t filtering distribution, using current measurement :math:`y_t`. The updates are according to .. math:: \hat{x}^F = \hat{x} + \Sigma G' (G \Sigma G' + R)^{-1} (y - G \hat{x}) ...
[ "r", "Updates", "the", "moments", "(", "x_hat", "Sigma", ")", "of", "the", "time", "t", "prior", "to", "the", "time", "t", "filtering", "distribution", "using", "current", "measurement", ":", "math", ":", "y_t", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/kalman.py#L180-L211
train
r Updates the moments of the time t prior to the current measurement y_t.
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/kalman.py
Kalman.filtered_to_forecast
def filtered_to_forecast(self): """ Updates the moments of the time t filtering distribution to the moments of the predictive distribution, which becomes the time t+1 prior """ # === simplify notation === # A, C = self.ss.A, self.ss.C Q = np.dot(C, C.T) ...
python
def filtered_to_forecast(self): """ Updates the moments of the time t filtering distribution to the moments of the predictive distribution, which becomes the time t+1 prior """ # === simplify notation === # A, C = self.ss.A, self.ss.C Q = np.dot(C, C.T) ...
[ "def", "filtered_to_forecast", "(", "self", ")", ":", "# === simplify notation === #", "A", ",", "C", "=", "self", ".", "ss", ".", "A", ",", "self", ".", "ss", ".", "C", "Q", "=", "np", ".", "dot", "(", "C", ",", "C", ".", "T", ")", "# === and then...
Updates the moments of the time t filtering distribution to the moments of the predictive distribution, which becomes the time t+1 prior
[ "Updates", "the", "moments", "of", "the", "time", "t", "filtering", "distribution", "to", "the", "moments", "of", "the", "predictive", "distribution", "which", "becomes", "the", "time", "t", "+", "1", "prior" ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/kalman.py#L213-L226
train
Updates the moments of the time t filtering distribution to the moments of the predictive distribution which becomes the time t + 1 prior
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/kalman.py
Kalman.stationary_values
def stationary_values(self, method='doubling'): """ Computes the limit of :math:`\Sigma_t` as t goes to infinity by solving the associated Riccati equation. The outputs are stored in the attributes `K_infinity` and `Sigma_infinity`. Computation is via the doubling algorithm (defa...
python
def stationary_values(self, method='doubling'): """ Computes the limit of :math:`\Sigma_t` as t goes to infinity by solving the associated Riccati equation. The outputs are stored in the attributes `K_infinity` and `Sigma_infinity`. Computation is via the doubling algorithm (defa...
[ "def", "stationary_values", "(", "self", ",", "method", "=", "'doubling'", ")", ":", "# === simplify notation === #", "A", ",", "C", ",", "G", ",", "H", "=", "self", ".", "ss", ".", "A", ",", "self", ".", "ss", ".", "C", ",", "self", ".", "ss", "."...
Computes the limit of :math:`\Sigma_t` as t goes to infinity by solving the associated Riccati equation. The outputs are stored in the attributes `K_infinity` and `Sigma_infinity`. Computation is via the doubling algorithm (default) or a QZ decomposition method (see the documentation in ...
[ "Computes", "the", "limit", "of", ":", "math", ":", "\\", "Sigma_t", "as", "t", "goes", "to", "infinity", "by", "solving", "the", "associated", "Riccati", "equation", ".", "The", "outputs", "are", "stored", "in", "the", "attributes", "K_infinity", "and", "...
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/kalman.py#L242-L277
train
Computes the stationary values of the entry - time sets for the current entry - time set.
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/lemke_howson.py
lemke_howson
def lemke_howson(g, init_pivot=0, max_iter=10**6, capping=None, full_output=False): """ Find one mixed-action Nash equilibrium of a 2-player normal form game by the Lemke-Howson algorithm [2]_, implemented with "complementary pivoting" (see, e.g., von Stengel [3]_ for details). Par...
python
def lemke_howson(g, init_pivot=0, max_iter=10**6, capping=None, full_output=False): """ Find one mixed-action Nash equilibrium of a 2-player normal form game by the Lemke-Howson algorithm [2]_, implemented with "complementary pivoting" (see, e.g., von Stengel [3]_ for details). Par...
[ "def", "lemke_howson", "(", "g", ",", "init_pivot", "=", "0", ",", "max_iter", "=", "10", "**", "6", ",", "capping", "=", "None", ",", "full_output", "=", "False", ")", ":", "try", ":", "N", "=", "g", ".", "N", "except", ":", "raise", "TypeError", ...
Find one mixed-action Nash equilibrium of a 2-player normal form game by the Lemke-Howson algorithm [2]_, implemented with "complementary pivoting" (see, e.g., von Stengel [3]_ for details). Parameters ---------- g : NormalFormGame NormalFormGame instance with 2 players. init_pivot : s...
[ "Find", "one", "mixed", "-", "action", "Nash", "equilibrium", "of", "a", "2", "-", "player", "normal", "form", "game", "by", "the", "Lemke", "-", "Howson", "algorithm", "[", "2", "]", "_", "implemented", "with", "complementary", "pivoting", "(", "see", "...
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/game_theory/lemke_howson.py#L16-L161
train
This routine returns a NashResult object for a 2 - player mixed - action Nash equilibrium of a NormalFormGame instance.
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/lemke_howson.py
_lemke_howson_capping
def _lemke_howson_capping(payoff_matrices, tableaux, bases, init_pivot, max_iter, capping): """ Execute the Lemke-Howson algorithm with the heuristics proposed by Codenotti et al. Parameters ---------- payoff_matrices : tuple(ndarray(ndim=2)) Tuple of two array...
python
def _lemke_howson_capping(payoff_matrices, tableaux, bases, init_pivot, max_iter, capping): """ Execute the Lemke-Howson algorithm with the heuristics proposed by Codenotti et al. Parameters ---------- payoff_matrices : tuple(ndarray(ndim=2)) Tuple of two array...
[ "def", "_lemke_howson_capping", "(", "payoff_matrices", ",", "tableaux", ",", "bases", ",", "init_pivot", ",", "max_iter", ",", "capping", ")", ":", "m", ",", "n", "=", "tableaux", "[", "1", "]", ".", "shape", "[", "0", "]", ",", "tableaux", "[", "0", ...
Execute the Lemke-Howson algorithm with the heuristics proposed by Codenotti et al. Parameters ---------- payoff_matrices : tuple(ndarray(ndim=2)) Tuple of two arrays representing payoff matrices, of shape (m, n) and (n, m), respectively. tableaux : tuple(ndarray(float, ndim=2)) ...
[ "Execute", "the", "Lemke", "-", "Howson", "algorithm", "with", "the", "heuristics", "proposed", "by", "Codenotti", "et", "al", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/game_theory/lemke_howson.py#L165-L223
train
Execute the Lemke - Howson algorithm with the heuristics proposed by the Codenotti et al.
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/lemke_howson.py
_initialize_tableaux
def _initialize_tableaux(payoff_matrices, tableaux, bases): """ Given a tuple of payoff matrices, initialize the tableau and basis arrays in place. For each player `i`, if `payoff_matrices[i].min()` is non-positive, then stored in the tableau are payoff values incremented by `abs(payoff_matrice...
python
def _initialize_tableaux(payoff_matrices, tableaux, bases): """ Given a tuple of payoff matrices, initialize the tableau and basis arrays in place. For each player `i`, if `payoff_matrices[i].min()` is non-positive, then stored in the tableau are payoff values incremented by `abs(payoff_matrice...
[ "def", "_initialize_tableaux", "(", "payoff_matrices", ",", "tableaux", ",", "bases", ")", ":", "nums_actions", "=", "payoff_matrices", "[", "0", "]", ".", "shape", "consts", "=", "np", ".", "zeros", "(", "2", ")", "# To be added to payoffs if min <= 0", "for", ...
Given a tuple of payoff matrices, initialize the tableau and basis arrays in place. For each player `i`, if `payoff_matrices[i].min()` is non-positive, then stored in the tableau are payoff values incremented by `abs(payoff_matrices[i].min()) + 1` (to ensure for the tableau not to have a negative e...
[ "Given", "a", "tuple", "of", "payoff", "matrices", "initialize", "the", "tableau", "and", "basis", "arrays", "in", "place", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/game_theory/lemke_howson.py#L227-L318
train
Initialize the basis and tableaux arrays in 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...
QuantEcon/QuantEcon.py
quantecon/game_theory/lemke_howson.py
_lemke_howson_tbl
def _lemke_howson_tbl(tableaux, bases, init_pivot, max_iter): """ Main body of the Lemke-Howson algorithm implementation. Perform the complementary pivoting. Modify `tablaux` and `bases` in place. Parameters ---------- tableaux : tuple(ndarray(float, ndim=2)) Tuple of two arrays co...
python
def _lemke_howson_tbl(tableaux, bases, init_pivot, max_iter): """ Main body of the Lemke-Howson algorithm implementation. Perform the complementary pivoting. Modify `tablaux` and `bases` in place. Parameters ---------- tableaux : tuple(ndarray(float, ndim=2)) Tuple of two arrays co...
[ "def", "_lemke_howson_tbl", "(", "tableaux", ",", "bases", ",", "init_pivot", ",", "max_iter", ")", ":", "init_player", "=", "0", "for", "k", "in", "bases", "[", "0", "]", ":", "if", "k", "==", "init_pivot", ":", "init_player", "=", "1", "break", "pls"...
Main body of the Lemke-Howson algorithm implementation. Perform the complementary pivoting. Modify `tablaux` and `bases` in place. Parameters ---------- tableaux : tuple(ndarray(float, ndim=2)) Tuple of two arrays containing the tableaux, of shape (n, m+n+1) and (m, m+n+1), respect...
[ "Main", "body", "of", "the", "Lemke", "-", "Howson", "algorithm", "implementation", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/game_theory/lemke_howson.py#L322-L421
train
This function is the main function of the Lemke - Howson algorithm implementation.
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/lemke_howson.py
_pivoting
def _pivoting(tableau, pivot, pivot_row): """ Perform a pivoting step. Modify `tableau` in place. Parameters ---------- tableau : ndarray(float, ndim=2) Array containing the tableau. pivot : scalar(int) Pivot. pivot_row : scalar(int) Pivot row index. Returns ...
python
def _pivoting(tableau, pivot, pivot_row): """ Perform a pivoting step. Modify `tableau` in place. Parameters ---------- tableau : ndarray(float, ndim=2) Array containing the tableau. pivot : scalar(int) Pivot. pivot_row : scalar(int) Pivot row index. Returns ...
[ "def", "_pivoting", "(", "tableau", ",", "pivot", ",", "pivot_row", ")", ":", "nrows", ",", "ncols", "=", "tableau", ".", "shape", "pivot_elt", "=", "tableau", "[", "pivot_row", ",", "pivot", "]", "for", "j", "in", "range", "(", "ncols", ")", ":", "t...
Perform a pivoting step. Modify `tableau` in place. Parameters ---------- tableau : ndarray(float, ndim=2) Array containing the tableau. pivot : scalar(int) Pivot. pivot_row : scalar(int) Pivot row index. Returns ------- tableau : ndarray(float, ndim=2) ...
[ "Perform", "a", "pivoting", "step", ".", "Modify", "tableau", "in", "place", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/game_theory/lemke_howson.py#L425-L461
train
Perform a pivoting step. Modify tableau in 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...
QuantEcon/QuantEcon.py
quantecon/game_theory/lemke_howson.py
_get_mixed_actions
def _get_mixed_actions(tableaux, bases): """ From `tableaux` and `bases`, extract non-slack basic variables and return a tuple of the corresponding, normalized mixed actions. Parameters ---------- tableaux : tuple(ndarray(float, ndim=2)) Tuple of two arrays containing the tableaux, of s...
python
def _get_mixed_actions(tableaux, bases): """ From `tableaux` and `bases`, extract non-slack basic variables and return a tuple of the corresponding, normalized mixed actions. Parameters ---------- tableaux : tuple(ndarray(float, ndim=2)) Tuple of two arrays containing the tableaux, of s...
[ "def", "_get_mixed_actions", "(", "tableaux", ",", "bases", ")", ":", "nums_actions", "=", "tableaux", "[", "1", "]", ".", "shape", "[", "0", "]", ",", "tableaux", "[", "0", "]", ".", "shape", "[", "0", "]", "num", "=", "nums_actions", "[", "0", "]...
From `tableaux` and `bases`, extract non-slack basic variables and return a tuple of the corresponding, normalized mixed actions. Parameters ---------- tableaux : tuple(ndarray(float, ndim=2)) Tuple of two arrays containing the tableaux, of shape (n, m+n+1) and (m, m+n+1), respectively....
[ "From", "tableaux", "and", "bases", "extract", "non", "-", "slack", "basic", "variables", "and", "return", "a", "tuple", "of", "the", "corresponding", "normalized", "mixed", "actions", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/game_theory/lemke_howson.py#L566-L603
train
Extract mixed actions from tableaux and bases and return a tuple of the corresponding normalized 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/quadsums.py
var_quadratic_sum
def var_quadratic_sum(A, C, H, beta, x0): r""" Computes the expected discounted quadratic sum .. math:: q(x_0) = \mathbb{E} \Big[ \sum_{t=0}^{\infty} \beta^t x_t' H x_t \Big] Here :math:`{x_t}` is the VAR process :math:`x_{t+1} = A x_t + C w_t` with :math:`{x_t}` standard normal and :math...
python
def var_quadratic_sum(A, C, H, beta, x0): r""" Computes the expected discounted quadratic sum .. math:: q(x_0) = \mathbb{E} \Big[ \sum_{t=0}^{\infty} \beta^t x_t' H x_t \Big] Here :math:`{x_t}` is the VAR process :math:`x_{t+1} = A x_t + C w_t` with :math:`{x_t}` standard normal and :math...
[ "def", "var_quadratic_sum", "(", "A", ",", "C", ",", "H", ",", "beta", ",", "x0", ")", ":", "# == Make sure that A, C, H and x0 are array_like == #", "A", ",", "C", ",", "H", "=", "list", "(", "map", "(", "np", ".", "atleast_2d", ",", "(", "A", ",", "C...
r""" Computes the expected discounted quadratic sum .. math:: q(x_0) = \mathbb{E} \Big[ \sum_{t=0}^{\infty} \beta^t x_t' H x_t \Big] Here :math:`{x_t}` is the VAR process :math:`x_{t+1} = A x_t + C w_t` with :math:`{x_t}` standard normal and :math:`x_0` the initial condition. Parameters ...
[ "r", "Computes", "the", "expected", "discounted", "quadratic", "sum" ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/quadsums.py#L14-L62
train
r Computes the expected discounted quadratic sum of A C H and x0.
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/quadsums.py
m_quadratic_sum
def m_quadratic_sum(A, B, max_it=50): r""" Computes the quadratic sum .. math:: V = \sum_{j=0}^{\infty} A^j B A^{j'} V is computed by solving the corresponding discrete lyapunov equation using the doubling algorithm. See the documentation of `util.solve_discrete_lyapunov` for more in...
python
def m_quadratic_sum(A, B, max_it=50): r""" Computes the quadratic sum .. math:: V = \sum_{j=0}^{\infty} A^j B A^{j'} V is computed by solving the corresponding discrete lyapunov equation using the doubling algorithm. See the documentation of `util.solve_discrete_lyapunov` for more in...
[ "def", "m_quadratic_sum", "(", "A", ",", "B", ",", "max_it", "=", "50", ")", ":", "gamma1", "=", "solve_discrete_lyapunov", "(", "A", ",", "B", ",", "max_it", ")", "return", "gamma1" ]
r""" Computes the quadratic sum .. math:: V = \sum_{j=0}^{\infty} A^j B A^{j'} V is computed by solving the corresponding discrete lyapunov equation using the doubling algorithm. See the documentation of `util.solve_discrete_lyapunov` for more information. Parameters ---------- ...
[ "r", "Computes", "the", "quadratic", "sum" ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/quadsums.py#L65-L99
train
r Computes the quadratic sum of A and B.
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/approximation.py
rouwenhorst
def rouwenhorst(n, ybar, sigma, rho): r""" Takes as inputs n, p, q, psi. It will then construct a markov chain that estimates an AR(1) process of: :math:`y_t = \bar{y} + \rho y_{t-1} + \varepsilon_t` where :math:`\varepsilon_t` is i.i.d. normal of mean 0, std dev of sigma The Rouwenhorst approx...
python
def rouwenhorst(n, ybar, sigma, rho): r""" Takes as inputs n, p, q, psi. It will then construct a markov chain that estimates an AR(1) process of: :math:`y_t = \bar{y} + \rho y_{t-1} + \varepsilon_t` where :math:`\varepsilon_t` is i.i.d. normal of mean 0, std dev of sigma The Rouwenhorst approx...
[ "def", "rouwenhorst", "(", "n", ",", "ybar", ",", "sigma", ",", "rho", ")", ":", "# Get the standard deviation of y", "y_sd", "=", "sqrt", "(", "sigma", "**", "2", "/", "(", "1", "-", "rho", "**", "2", ")", ")", "# Given the moments of our process we can fin...
r""" Takes as inputs n, p, q, psi. It will then construct a markov chain that estimates an AR(1) process of: :math:`y_t = \bar{y} + \rho y_{t-1} + \varepsilon_t` where :math:`\varepsilon_t` is i.i.d. normal of mean 0, std dev of sigma The Rouwenhorst approximation uses the following recursive defin...
[ "r", "Takes", "as", "inputs", "n", "p", "q", "psi", ".", "It", "will", "then", "construct", "a", "markov", "chain", "that", "estimates", "an", "AR", "(", "1", ")", "process", "of", ":", ":", "math", ":", "y_t", "=", "\\", "bar", "{", "y", "}", ...
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/markov/approximation.py#L15-L135
train
r Returns a new markov chain that approximates a distribution of a given number of points ybar sigma and rho.
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/approximation.py
tauchen
def tauchen(rho, sigma_u, m=3, n=7): r""" Computes a Markov chain associated with a discretized version of the linear Gaussian AR(1) process .. math:: y_{t+1} = \rho y_t + u_{t+1} using Tauchen's method. Here :math:`{u_t}` is an i.i.d. Gaussian process with zero mean. Parameters ...
python
def tauchen(rho, sigma_u, m=3, n=7): r""" Computes a Markov chain associated with a discretized version of the linear Gaussian AR(1) process .. math:: y_{t+1} = \rho y_t + u_{t+1} using Tauchen's method. Here :math:`{u_t}` is an i.i.d. Gaussian process with zero mean. Parameters ...
[ "def", "tauchen", "(", "rho", ",", "sigma_u", ",", "m", "=", "3", ",", "n", "=", "7", ")", ":", "# standard deviation of y_t", "std_y", "=", "np", ".", "sqrt", "(", "sigma_u", "**", "2", "/", "(", "1", "-", "rho", "**", "2", ")", ")", "# top of d...
r""" Computes a Markov chain associated with a discretized version of the linear Gaussian AR(1) process .. math:: y_{t+1} = \rho y_t + u_{t+1} using Tauchen's method. Here :math:`{u_t}` is an i.i.d. Gaussian process with zero mean. Parameters ---------- rho : scalar(float) ...
[ "r", "Computes", "a", "Markov", "chain", "associated", "with", "a", "discretized", "version", "of", "the", "linear", "Gaussian", "AR", "(", "1", ")", "process" ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/markov/approximation.py#L138-L189
train
r This function computes a linear Gaussian AR ( 1 ) process and returns a MarkovChain object that stores the transition matrix and state values of the next state.
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/optimize/nelder_mead.py
nelder_mead
def nelder_mead(fun, x0, bounds=np.array([[], []]).T, args=(), tol_f=1e-10, tol_x=1e-10, max_iter=1000): """ .. highlight:: none Maximize a scalar-valued function with one or more variables using the Nelder-Mead method. This function is JIT-compiled in `nopython` mode using Numba. ...
python
def nelder_mead(fun, x0, bounds=np.array([[], []]).T, args=(), tol_f=1e-10, tol_x=1e-10, max_iter=1000): """ .. highlight:: none Maximize a scalar-valued function with one or more variables using the Nelder-Mead method. This function is JIT-compiled in `nopython` mode using Numba. ...
[ "def", "nelder_mead", "(", "fun", ",", "x0", ",", "bounds", "=", "np", ".", "array", "(", "[", "[", "]", ",", "[", "]", "]", ")", ".", "T", ",", "args", "=", "(", ")", ",", "tol_f", "=", "1e-10", ",", "tol_x", "=", "1e-10", ",", "max_iter", ...
.. highlight:: none Maximize a scalar-valued function with one or more variables using the Nelder-Mead method. This function is JIT-compiled in `nopython` mode using Numba. Parameters ---------- fun : callable The objective function to be maximized: `fun(x, *args) -> float` wh...
[ "..", "highlight", "::", "none" ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/optimize/nelder_mead.py#L15-L122
train
Maximize a scalar - valued function with one or more independent variables using Nelder - Mead method.
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/optimize/nelder_mead.py
_nelder_mead_algorithm
def _nelder_mead_algorithm(fun, vertices, bounds=np.array([[], []]).T, args=(), ρ=1., χ=2., γ=0.5, σ=0.5, tol_f=1e-8, tol_x=1e-8, max_iter=1000): """ .. highlight:: none Implements the Nelder-Mead algorithm described in Lagarias et al. (1998) modifi...
python
def _nelder_mead_algorithm(fun, vertices, bounds=np.array([[], []]).T, args=(), ρ=1., χ=2., γ=0.5, σ=0.5, tol_f=1e-8, tol_x=1e-8, max_iter=1000): """ .. highlight:: none Implements the Nelder-Mead algorithm described in Lagarias et al. (1998) modifi...
[ "def", "_nelder_mead_algorithm", "(", "fun", ",", "vertices", ",", "bounds", "=", "np", ".", "array", "(", "[", "[", "]", ",", "[", "]", "]", ")", ".", "T", ",", "args", "=", "(", ")", ",", "ρ=", "1", ".,", " ", "=2", ".", ", ", "γ", "0.", ...
.. highlight:: none Implements the Nelder-Mead algorithm described in Lagarias et al. (1998) modified to maximize instead of minimizing. JIT-compiled in `nopython` mode using Numba. Parameters ---------- fun : callable The objective function to be maximized. `fun(x, *args) ...
[ "..", "highlight", "::", "none" ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/optimize/nelder_mead.py#L126-L290
train
This function is used to maximize the Nelder - Mead algorithm.
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/optimize/nelder_mead.py
_initialize_simplex
def _initialize_simplex(x0, bounds): """ Generates an initial simplex for the Nelder-Mead method. JIT-compiled in `nopython` mode using Numba. Parameters ---------- x0 : ndarray(float, ndim=1) Initial guess. Array of real elements of size (n,), where ‘n’ is the number of indepen...
python
def _initialize_simplex(x0, bounds): """ Generates an initial simplex for the Nelder-Mead method. JIT-compiled in `nopython` mode using Numba. Parameters ---------- x0 : ndarray(float, ndim=1) Initial guess. Array of real elements of size (n,), where ‘n’ is the number of indepen...
[ "def", "_initialize_simplex", "(", "x0", ",", "bounds", ")", ":", "n", "=", "x0", ".", "size", "vertices", "=", "np", ".", "empty", "(", "(", "n", "+", "1", ",", "n", ")", ",", "dtype", "=", "np", ".", "float64", ")", "# Broadcast x0 on row dimension...
Generates an initial simplex for the Nelder-Mead method. JIT-compiled in `nopython` mode using Numba. Parameters ---------- x0 : ndarray(float, ndim=1) Initial guess. Array of real elements of size (n,), where ‘n’ is the number of independent variables. bounds: ndarray(float, ndim=...
[ "Generates", "an", "initial", "simplex", "for", "the", "Nelder", "-", "Mead", "method", ".", "JIT", "-", "compiled", "in", "nopython", "mode", "using", "Numba", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/optimize/nelder_mead.py#L294-L331
train
Generates an initial simplex for the Nelder - Mead method using Numba.
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/optimize/nelder_mead.py
_check_params
def _check_params(ρ, χ, γ, σ, bounds, n): """ Checks whether the parameters for the Nelder-Mead algorithm are valid. JIT-compiled in `nopython` mode using Numba. Parameters ---------- ρ : scalar(float) Reflection parameter. Must be strictly greater than 0. χ : scalar(float) ...
python
def _check_params(ρ, χ, γ, σ, bounds, n): """ Checks whether the parameters for the Nelder-Mead algorithm are valid. JIT-compiled in `nopython` mode using Numba. Parameters ---------- ρ : scalar(float) Reflection parameter. Must be strictly greater than 0. χ : scalar(float) ...
[ "def", "_check_params", "(", "ρ,", " ", ", ", "γ", " σ", ",", "bo", "u", "ds, n)", ":", "", "", "", "if", "ρ ", " ", ":", "", "raise", "ValueError", "(", "\"ρ must be strictly greater than 0.\")", "", "if", "χ ", " ", ":", "", "raise", "ValueError", ...
Checks whether the parameters for the Nelder-Mead algorithm are valid. JIT-compiled in `nopython` mode using Numba. Parameters ---------- ρ : scalar(float) Reflection parameter. Must be strictly greater than 0. χ : scalar(float) Expansion parameter. Must be strictly greater than ma...
[ "Checks", "whether", "the", "parameters", "for", "the", "Nelder", "-", "Mead", "algorithm", "are", "valid", ".", "JIT", "-", "compiled", "in", "nopython", "mode", "using", "Numba", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/optimize/nelder_mead.py#L335-L375
train
Checks whether the parameters for the Nelder - Mead algorithm are valid.
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/optimize/nelder_mead.py
_check_bounds
def _check_bounds(x, bounds): """ Checks whether `x` is within `bounds`. JIT-compiled in `nopython` mode using Numba. Parameters ---------- x : ndarray(float, ndim=1) 1-D array with shape (n,) of independent variables. bounds: ndarray(float, ndim=2) Sequence of (min, max) p...
python
def _check_bounds(x, bounds): """ Checks whether `x` is within `bounds`. JIT-compiled in `nopython` mode using Numba. Parameters ---------- x : ndarray(float, ndim=1) 1-D array with shape (n,) of independent variables. bounds: ndarray(float, ndim=2) Sequence of (min, max) p...
[ "def", "_check_bounds", "(", "x", ",", "bounds", ")", ":", "if", "bounds", ".", "shape", "==", "(", "0", ",", "2", ")", ":", "return", "True", "else", ":", "return", "(", "(", "np", ".", "atleast_2d", "(", "bounds", ")", "[", ":", ",", "0", "]"...
Checks whether `x` is within `bounds`. JIT-compiled in `nopython` mode using Numba. Parameters ---------- x : ndarray(float, ndim=1) 1-D array with shape (n,) of independent variables. bounds: ndarray(float, ndim=2) Sequence of (min, max) pairs for each element in x. Returns ...
[ "Checks", "whether", "x", "is", "within", "bounds", ".", "JIT", "-", "compiled", "in", "nopython", "mode", "using", "Numba", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/optimize/nelder_mead.py#L379-L402
train
Checks whether x is within bounds. JIT - compiled in nopython mode uses Numba.
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/optimize/nelder_mead.py
_neg_bounded_fun
def _neg_bounded_fun(fun, bounds, x, args=()): """ Wrapper for bounding and taking the negative of `fun` for the Nelder-Mead algorithm. JIT-compiled in `nopython` mode using Numba. Parameters ---------- fun : callable The objective function to be minimized. `fun(x, *args) ->...
python
def _neg_bounded_fun(fun, bounds, x, args=()): """ Wrapper for bounding and taking the negative of `fun` for the Nelder-Mead algorithm. JIT-compiled in `nopython` mode using Numba. Parameters ---------- fun : callable The objective function to be minimized. `fun(x, *args) ->...
[ "def", "_neg_bounded_fun", "(", "fun", ",", "bounds", ",", "x", ",", "args", "=", "(", ")", ")", ":", "if", "_check_bounds", "(", "x", ",", "bounds", ")", ":", "return", "-", "fun", "(", "x", ",", "*", "args", ")", "else", ":", "return", "np", ...
Wrapper for bounding and taking the negative of `fun` for the Nelder-Mead algorithm. JIT-compiled in `nopython` mode using Numba. Parameters ---------- fun : callable The objective function to be minimized. `fun(x, *args) -> float` where x is an 1-D array with shape (n,) and...
[ "Wrapper", "for", "bounding", "and", "taking", "the", "negative", "of", "fun", "for", "the", "Nelder", "-", "Mead", "algorithm", ".", "JIT", "-", "compiled", "in", "nopython", "mode", "using", "Numba", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/optimize/nelder_mead.py#L406-L439
train
Wrapper for bounding and taking the negative of fun for the base Nelder - Mead algorithm.
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/matrix_eqn.py
solve_discrete_lyapunov
def solve_discrete_lyapunov(A, B, max_it=50, method="doubling"): r""" Computes the solution to the discrete lyapunov equation .. math:: AXA' - X + B = 0 :math:`X` is computed by using a doubling algorithm. In particular, we iterate to convergence on :math:`X_j` with the following recursio...
python
def solve_discrete_lyapunov(A, B, max_it=50, method="doubling"): r""" Computes the solution to the discrete lyapunov equation .. math:: AXA' - X + B = 0 :math:`X` is computed by using a doubling algorithm. In particular, we iterate to convergence on :math:`X_j` with the following recursio...
[ "def", "solve_discrete_lyapunov", "(", "A", ",", "B", ",", "max_it", "=", "50", ",", "method", "=", "\"doubling\"", ")", ":", "if", "method", "==", "\"doubling\"", ":", "A", ",", "B", "=", "list", "(", "map", "(", "np", ".", "atleast_2d", ",", "[", ...
r""" Computes the solution to the discrete lyapunov equation .. math:: AXA' - X + B = 0 :math:`X` is computed by using a doubling algorithm. In particular, we iterate to convergence on :math:`X_j` with the following recursions for :math:`j = 1, 2, \dots` starting from :math:`X_0 = B`, :ma...
[ "r", "Computes", "the", "solution", "to", "the", "discrete", "lyapunov", "equation" ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/matrix_eqn.py#L22-L96
train
r Solve the discrete lyapunov 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/matrix_eqn.py
solve_discrete_riccati
def solve_discrete_riccati(A, B, Q, R, N=None, tolerance=1e-10, max_iter=500, method="doubling"): """ Solves the discrete-time algebraic Riccati equation .. math:: X = A'XA - (N + B'XA)'(B'XB + R)^{-1}(N + B'XA) + Q Computation is via a modified structured doubling ...
python
def solve_discrete_riccati(A, B, Q, R, N=None, tolerance=1e-10, max_iter=500, method="doubling"): """ Solves the discrete-time algebraic Riccati equation .. math:: X = A'XA - (N + B'XA)'(B'XB + R)^{-1}(N + B'XA) + Q Computation is via a modified structured doubling ...
[ "def", "solve_discrete_riccati", "(", "A", ",", "B", ",", "Q", ",", "R", ",", "N", "=", "None", ",", "tolerance", "=", "1e-10", ",", "max_iter", "=", "500", ",", "method", "=", "\"doubling\"", ")", ":", "methods", "=", "[", "'doubling'", ",", "'qz'",...
Solves the discrete-time algebraic Riccati equation .. math:: X = A'XA - (N + B'XA)'(B'XB + R)^{-1}(N + B'XA) + Q Computation is via a modified structured doubling algorithm, an explanation of which can be found in the reference below, if `method="doubling"` (default), and via a QZ decomposit...
[ "Solves", "the", "discrete", "-", "time", "algebraic", "Riccati", "equation" ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/matrix_eqn.py#L99-L225
train
Solve the discrete - time algebraic Riccati equation.
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/util/combinatorics.py
next_k_array
def next_k_array(a): """ Given an array `a` of k distinct nonnegative integers, sorted in ascending order, return the next k-array in the lexicographic ordering of the descending sequences of the elements [1]_. `a` is modified in place. Parameters ---------- a : ndarray(int, ndim=1) ...
python
def next_k_array(a): """ Given an array `a` of k distinct nonnegative integers, sorted in ascending order, return the next k-array in the lexicographic ordering of the descending sequences of the elements [1]_. `a` is modified in place. Parameters ---------- a : ndarray(int, ndim=1) ...
[ "def", "next_k_array", "(", "a", ")", ":", "# Logic taken from Algotirhm T in D. Knuth, The Art of Computer", "# Programming, Section 7.2.1.3 \"Generating All Combinations\".", "k", "=", "len", "(", "a", ")", "if", "k", "==", "1", "or", "a", "[", "0", "]", "+", "1", ...
Given an array `a` of k distinct nonnegative integers, sorted in ascending order, return the next k-array in the lexicographic ordering of the descending sequences of the elements [1]_. `a` is modified in place. Parameters ---------- a : ndarray(int, ndim=1) Array of length k. Retu...
[ "Given", "an", "array", "a", "of", "k", "distinct", "nonnegative", "integers", "sorted", "in", "ascending", "order", "return", "the", "next", "k", "-", "array", "in", "the", "lexicographic", "ordering", "of", "the", "descending", "sequences", "of", "the", "e...
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/util/combinatorics.py#L12-L70
train
Given an array a of k distinct nonnegative integers return the next k - array in the 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/util/combinatorics.py
k_array_rank
def k_array_rank(a): """ Given an array `a` of k distinct nonnegative integers, sorted in ascending order, return its ranking in the lexicographic ordering of the descending sequences of the elements [1]_. Parameters ---------- a : ndarray(int, ndim=1) Array of length k. Return...
python
def k_array_rank(a): """ Given an array `a` of k distinct nonnegative integers, sorted in ascending order, return its ranking in the lexicographic ordering of the descending sequences of the elements [1]_. Parameters ---------- a : ndarray(int, ndim=1) Array of length k. Return...
[ "def", "k_array_rank", "(", "a", ")", ":", "k", "=", "len", "(", "a", ")", "idx", "=", "int", "(", "a", "[", "0", "]", ")", "# Convert to Python int", "for", "i", "in", "range", "(", "1", ",", "k", ")", ":", "idx", "+=", "comb", "(", "a", "["...
Given an array `a` of k distinct nonnegative integers, sorted in ascending order, return its ranking in the lexicographic ordering of the descending sequences of the elements [1]_. Parameters ---------- a : ndarray(int, ndim=1) Array of length k. Returns ------- idx : scalar(in...
[ "Given", "an", "array", "a", "of", "k", "distinct", "nonnegative", "integers", "sorted", "in", "ascending", "order", "return", "its", "ranking", "in", "the", "lexicographic", "ordering", "of", "the", "descending", "sequences", "of", "the", "elements", "[", "1"...
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/util/combinatorics.py#L73-L100
train
Returns the ranking of the k distinct nonnegative integers in the lexicographic ordering of the elements of the elements in the array a.
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/util/combinatorics.py
k_array_rank_jit
def k_array_rank_jit(a): """ Numba jit version of `k_array_rank`. Notes ----- An incorrect value will be returned without warning or error if overflow occurs during the computation. It is the user's responsibility to ensure that the rank of the input array fits within the range of possi...
python
def k_array_rank_jit(a): """ Numba jit version of `k_array_rank`. Notes ----- An incorrect value will be returned without warning or error if overflow occurs during the computation. It is the user's responsibility to ensure that the rank of the input array fits within the range of possi...
[ "def", "k_array_rank_jit", "(", "a", ")", ":", "k", "=", "len", "(", "a", ")", "idx", "=", "a", "[", "0", "]", "for", "i", "in", "range", "(", "1", ",", "k", ")", ":", "idx", "+=", "comb_jit", "(", "a", "[", "i", "]", ",", "i", "+", "1", ...
Numba jit version of `k_array_rank`. Notes ----- An incorrect value will be returned without warning or error if overflow occurs during the computation. It is the user's responsibility to ensure that the rank of the input array fits within the range of possible values of `np.intp`; a sufficient...
[ "Numba", "jit", "version", "of", "k_array_rank", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/util/combinatorics.py#L104-L122
train
Numba jit version of k_array_rank.
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/util/numba.py
_numba_linalg_solve
def _numba_linalg_solve(a, b): """ Solve the linear equation ax = b directly calling a Numba internal function. The data in `a` and `b` are interpreted in Fortran order, and dtype of `a` and `b` must be the same, one of {float32, float64, complex64, complex128}. `a` and `b` are modified in place, an...
python
def _numba_linalg_solve(a, b): """ Solve the linear equation ax = b directly calling a Numba internal function. The data in `a` and `b` are interpreted in Fortran order, and dtype of `a` and `b` must be the same, one of {float32, float64, complex64, complex128}. `a` and `b` are modified in place, an...
[ "def", "_numba_linalg_solve", "(", "a", ",", "b", ")", ":", "numba_xgesv", "=", "_LAPACK", "(", ")", ".", "numba_xgesv", "(", "a", ".", "dtype", ")", "kind", "=", "ord", "(", "_blas_kinds", "[", "a", ".", "dtype", "]", ")", "def", "_numba_linalg_solve_...
Solve the linear equation ax = b directly calling a Numba internal function. The data in `a` and `b` are interpreted in Fortran order, and dtype of `a` and `b` must be the same, one of {float32, float64, complex64, complex128}. `a` and `b` are modified in place, and the solution is stored in `b`. *No er...
[ "Solve", "the", "linear", "equation", "ax", "=", "b", "directly", "calling", "a", "Numba", "internal", "function", ".", "The", "data", "in", "a", "and", "b", "are", "interpreted", "in", "Fortran", "order", "and", "dtype", "of", "a", "and", "b", "must", ...
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/util/numba.py#L20-L71
train
Return a function that solves the linear equation ax = b directly calling a Numba internal 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/util/numba.py
comb_jit
def comb_jit(N, k): """ Numba jitted function that computes N choose k. Return `0` if the outcome exceeds the maximum value of `np.intp` or if N < 0, k < 0, or k > N. Parameters ---------- N : scalar(int) k : scalar(int) Returns ------- val : scalar(int) """ # Fro...
python
def comb_jit(N, k): """ Numba jitted function that computes N choose k. Return `0` if the outcome exceeds the maximum value of `np.intp` or if N < 0, k < 0, or k > N. Parameters ---------- N : scalar(int) k : scalar(int) Returns ------- val : scalar(int) """ # Fro...
[ "def", "comb_jit", "(", "N", ",", "k", ")", ":", "# From scipy.special._comb_int_long", "# github.com/scipy/scipy/blob/v1.0.0/scipy/special/_comb.pyx", "INTP_MAX", "=", "np", ".", "iinfo", "(", "np", ".", "intp", ")", ".", "max", "if", "N", "<", "0", "or", "k", ...
Numba jitted function that computes N choose k. Return `0` if the outcome exceeds the maximum value of `np.intp` or if N < 0, k < 0, or k > N. Parameters ---------- N : scalar(int) k : scalar(int) Returns ------- val : scalar(int)
[ "Numba", "jitted", "function", "that", "computes", "N", "choose", "k", ".", "Return", "0", "if", "the", "outcome", "exceeds", "the", "maximum", "value", "of", "np", ".", "intp", "or", "if", "N", "<", "0", "k", "<", "0", "or", "k", ">", "N", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/util/numba.py#L75-L117
train
N choose k returns N if the outcome exceeds the maximum value of np. intp
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/ivp.py
IVP._integrate_fixed_trajectory
def _integrate_fixed_trajectory(self, h, T, step, relax): """Generates a solution trajectory of fixed length.""" # initialize the solution using initial condition solution = np.hstack((self.t, self.y)) while self.successful(): self.integrate(self.t + h, step, relax) ...
python
def _integrate_fixed_trajectory(self, h, T, step, relax): """Generates a solution trajectory of fixed length.""" # initialize the solution using initial condition solution = np.hstack((self.t, self.y)) while self.successful(): self.integrate(self.t + h, step, relax) ...
[ "def", "_integrate_fixed_trajectory", "(", "self", ",", "h", ",", "T", ",", "step", ",", "relax", ")", ":", "# initialize the solution using initial condition", "solution", "=", "np", ".", "hstack", "(", "(", "self", ".", "t", ",", "self", ".", "y", ")", "...
Generates a solution trajectory of fixed length.
[ "Generates", "a", "solution", "trajectory", "of", "fixed", "length", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/ivp.py#L48-L66
train
Generates a solution trajectory of fixed length.
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/ivp.py
IVP._integrate_variable_trajectory
def _integrate_variable_trajectory(self, h, g, tol, step, relax): """Generates a solution trajectory of variable length.""" # initialize the solution using initial condition solution = np.hstack((self.t, self.y)) while self.successful(): self.integrate(self.t + h, step, rel...
python
def _integrate_variable_trajectory(self, h, g, tol, step, relax): """Generates a solution trajectory of variable length.""" # initialize the solution using initial condition solution = np.hstack((self.t, self.y)) while self.successful(): self.integrate(self.t + h, step, rel...
[ "def", "_integrate_variable_trajectory", "(", "self", ",", "h", ",", "g", ",", "tol", ",", "step", ",", "relax", ")", ":", "# initialize the solution using initial condition", "solution", "=", "np", ".", "hstack", "(", "(", "self", ".", "t", ",", "self", "."...
Generates a solution trajectory of variable length.
[ "Generates", "a", "solution", "trajectory", "of", "variable", "length", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/ivp.py#L68-L84
train
Generates a solution trajectory of variable length.
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/ivp.py
IVP._initialize_integrator
def _initialize_integrator(self, t0, y0, integrator, **kwargs): """Initializes the integrator prior to integration.""" # set the initial condition self.set_initial_value(y0, t0) # select the integrator self.set_integrator(integrator, **kwargs)
python
def _initialize_integrator(self, t0, y0, integrator, **kwargs): """Initializes the integrator prior to integration.""" # set the initial condition self.set_initial_value(y0, t0) # select the integrator self.set_integrator(integrator, **kwargs)
[ "def", "_initialize_integrator", "(", "self", ",", "t0", ",", "y0", ",", "integrator", ",", "*", "*", "kwargs", ")", ":", "# set the initial condition", "self", ".", "set_initial_value", "(", "y0", ",", "t0", ")", "# select the integrator", "self", ".", "set_i...
Initializes the integrator prior to integration.
[ "Initializes", "the", "integrator", "prior", "to", "integration", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/ivp.py#L86-L92
train
Initializes the integrator prior to integration.
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/ivp.py
IVP.compute_residual
def compute_residual(self, traj, ti, k=3, ext=2): r""" The residual is the difference between the derivative of the B-spline approximation of the solution trajectory and the right-hand side of the original ODE evaluated along the approximated solution trajectory. Parameters ...
python
def compute_residual(self, traj, ti, k=3, ext=2): r""" The residual is the difference between the derivative of the B-spline approximation of the solution trajectory and the right-hand side of the original ODE evaluated along the approximated solution trajectory. Parameters ...
[ "def", "compute_residual", "(", "self", ",", "traj", ",", "ti", ",", "k", "=", "3", ",", "ext", "=", "2", ")", ":", "# B-spline approximations of the solution and its derivative", "soln", "=", "self", ".", "interpolate", "(", "traj", ",", "ti", ",", "k", "...
r""" The residual is the difference between the derivative of the B-spline approximation of the solution trajectory and the right-hand side of the original ODE evaluated along the approximated solution trajectory. Parameters ---------- traj : array_like (float) ...
[ "r", "The", "residual", "is", "the", "difference", "between", "the", "derivative", "of", "the", "B", "-", "spline", "approximation", "of", "the", "solution", "trajectory", "and", "the", "right", "-", "hand", "side", "of", "the", "original", "ODE", "evaluated...
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/ivp.py#L94-L137
train
r Compute the residual of the knot sequence of the current knot sequence.
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/ivp.py
IVP.solve
def solve(self, t0, y0, h=1.0, T=None, g=None, tol=None, integrator='dopri5', step=False, relax=False, **kwargs): r""" Solve the IVP by integrating the ODE given some initial condition. Parameters ---------- t0 : float Initial condition for the independ...
python
def solve(self, t0, y0, h=1.0, T=None, g=None, tol=None, integrator='dopri5', step=False, relax=False, **kwargs): r""" Solve the IVP by integrating the ODE given some initial condition. Parameters ---------- t0 : float Initial condition for the independ...
[ "def", "solve", "(", "self", ",", "t0", ",", "y0", ",", "h", "=", "1.0", ",", "T", "=", "None", ",", "g", "=", "None", ",", "tol", "=", "None", ",", "integrator", "=", "'dopri5'", ",", "step", "=", "False", ",", "relax", "=", "False", ",", "*...
r""" Solve the IVP by integrating the ODE given some initial condition. Parameters ---------- t0 : float Initial condition for the independent variable. y0 : array_like (float, shape=(n,)) Initial condition for the dependent variables. h : float, ...
[ "r", "Solve", "the", "IVP", "by", "integrating", "the", "ODE", "given", "some", "initial", "condition", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/ivp.py#L139-L191
train
r Solve the IVP by integrating the ODE given some initial condition.
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/ivp.py
IVP.interpolate
def interpolate(self, traj, ti, k=3, der=0, ext=2): r""" Parametric B-spline interpolation in N-dimensions. Parameters ---------- traj : array_like (float) Solution trajectory providing the data points for constructing the B-spline representation. ...
python
def interpolate(self, traj, ti, k=3, der=0, ext=2): r""" Parametric B-spline interpolation in N-dimensions. Parameters ---------- traj : array_like (float) Solution trajectory providing the data points for constructing the B-spline representation. ...
[ "def", "interpolate", "(", "self", ",", "traj", ",", "ti", ",", "k", "=", "3", ",", "der", "=", "0", ",", "ext", "=", "2", ")", ":", "# array of parameter values", "u", "=", "traj", "[", ":", ",", "0", "]", "# build list of input arrays", "n", "=", ...
r""" Parametric B-spline interpolation in N-dimensions. Parameters ---------- traj : array_like (float) Solution trajectory providing the data points for constructing the B-spline representation. ti : array_like (float) Array of values for the...
[ "r", "Parametric", "B", "-", "spline", "interpolation", "in", "N", "-", "dimensions", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/ivp.py#L193-L238
train
r Interpolate the knot sequence at the specified location.
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/inequality.py
lorenz_curve
def lorenz_curve(y): """ Calculates the Lorenz Curve, a graphical representation of the distribution of income or wealth. It returns the cumulative share of people (x-axis) and the cumulative share of income earned Parameters ---------- y : array_like(float or int, ndim=1) Array of...
python
def lorenz_curve(y): """ Calculates the Lorenz Curve, a graphical representation of the distribution of income or wealth. It returns the cumulative share of people (x-axis) and the cumulative share of income earned Parameters ---------- y : array_like(float or int, ndim=1) Array of...
[ "def", "lorenz_curve", "(", "y", ")", ":", "n", "=", "len", "(", "y", ")", "y", "=", "np", ".", "sort", "(", "y", ")", "s", "=", "np", ".", "zeros", "(", "n", "+", "1", ")", "s", "[", "1", ":", "]", "=", "np", ".", "cumsum", "(", "y", ...
Calculates the Lorenz Curve, a graphical representation of the distribution of income or wealth. It returns the cumulative share of people (x-axis) and the cumulative share of income earned Parameters ---------- y : array_like(float or int, ndim=1) Array of income/wealth for each individua...
[ "Calculates", "the", "Lorenz", "Curve", "a", "graphical", "representation", "of", "the", "distribution", "of", "income", "or", "wealth", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/inequality.py#L11-L52
train
Calculates the Lorenz curve for a set of income and wealth.
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/inequality.py
gini_coefficient
def gini_coefficient(y): r""" Implements the Gini inequality index Parameters ----------- y : array_like(float) Array of income/wealth for each individual. Ordered or unordered is fine Returns ------- Gini index: float The gini index describing the inequality of the arr...
python
def gini_coefficient(y): r""" Implements the Gini inequality index Parameters ----------- y : array_like(float) Array of income/wealth for each individual. Ordered or unordered is fine Returns ------- Gini index: float The gini index describing the inequality of the arr...
[ "def", "gini_coefficient", "(", "y", ")", ":", "n", "=", "len", "(", "y", ")", "i_sum", "=", "np", ".", "zeros", "(", "n", ")", "for", "i", "in", "prange", "(", "n", ")", ":", "for", "j", "in", "range", "(", "n", ")", ":", "i_sum", "[", "i"...
r""" Implements the Gini inequality index Parameters ----------- y : array_like(float) Array of income/wealth for each individual. Ordered or unordered is fine Returns ------- Gini index: float The gini index describing the inequality of the array of income/wealth Refe...
[ "r", "Implements", "the", "Gini", "inequality", "index" ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/inequality.py#L56-L80
train
r Implements the Gini inequality 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/inequality.py
shorrocks_index
def shorrocks_index(A): r""" Implements Shorrocks mobility index Parameters ----------- A : array_like(float) Square matrix with transition probabilities (mobility matrix) of dimension m Returns -------- Shorrocks index: float The Shorrocks mobility index calcul...
python
def shorrocks_index(A): r""" Implements Shorrocks mobility index Parameters ----------- A : array_like(float) Square matrix with transition probabilities (mobility matrix) of dimension m Returns -------- Shorrocks index: float The Shorrocks mobility index calcul...
[ "def", "shorrocks_index", "(", "A", ")", ":", "A", "=", "np", ".", "asarray", "(", "A", ")", "# Convert to array if not already", "m", ",", "n", "=", "A", ".", "shape", "if", "m", "!=", "n", ":", "raise", "ValueError", "(", "'A must be a square matrix'", ...
r""" Implements Shorrocks mobility index Parameters ----------- A : array_like(float) Square matrix with transition probabilities (mobility matrix) of dimension m Returns -------- Shorrocks index: float The Shorrocks mobility index calculated as .. math:: ...
[ "r", "Implements", "Shorrocks", "mobility", "index" ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/inequality.py#L83-L119
train
r Calculates the Shorrocks mobility index for a given matrix A.
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/discrete_rv.py
DiscreteRV.q
def q(self, val): """ Setter method for q. """ self._q = np.asarray(val) self.Q = cumsum(val)
python
def q(self, val): """ Setter method for q. """ self._q = np.asarray(val) self.Q = cumsum(val)
[ "def", "q", "(", "self", ",", "val", ")", ":", "self", ".", "_q", "=", "np", ".", "asarray", "(", "val", ")", "self", ".", "Q", "=", "cumsum", "(", "val", ")" ]
Setter method for q.
[ "Setter", "method", "for", "q", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/discrete_rv.py#L49-L55
train
Set the internal _q and Q 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...
QuantEcon/QuantEcon.py
quantecon/discrete_rv.py
DiscreteRV.draw
def draw(self, k=1, random_state=None): """ Returns k draws from q. For each such draw, the value i is returned with probability q[i]. Parameters ----------- k : scalar(int), optional Number of draws to be returned random_state : int or np.r...
python
def draw(self, k=1, random_state=None): """ Returns k draws from q. For each such draw, the value i is returned with probability q[i]. Parameters ----------- k : scalar(int), optional Number of draws to be returned random_state : int or np.r...
[ "def", "draw", "(", "self", ",", "k", "=", "1", ",", "random_state", "=", "None", ")", ":", "random_state", "=", "check_random_state", "(", "random_state", ")", "return", "self", ".", "Q", ".", "searchsorted", "(", "random_state", ".", "uniform", "(", "0...
Returns k draws from q. For each such draw, the value i is returned with probability q[i]. Parameters ----------- k : scalar(int), optional Number of draws to be returned random_state : int or np.random.RandomState, optional Random seed (integer...
[ "Returns", "k", "draws", "from", "q", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/discrete_rv.py#L57-L84
train
Returns k draws from the probability set.
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/random.py
random_markov_chain
def random_markov_chain(n, k=None, sparse=False, random_state=None): """ Return a randomly sampled MarkovChain instance with n states, where each state has k states with positive transition probability. Parameters ---------- n : scalar(int) Number of states. k : scalar(int), option...
python
def random_markov_chain(n, k=None, sparse=False, random_state=None): """ Return a randomly sampled MarkovChain instance with n states, where each state has k states with positive transition probability. Parameters ---------- n : scalar(int) Number of states. k : scalar(int), option...
[ "def", "random_markov_chain", "(", "n", ",", "k", "=", "None", ",", "sparse", "=", "False", ",", "random_state", "=", "None", ")", ":", "P", "=", "random_stochastic_matrix", "(", "n", ",", "k", ",", "sparse", ",", "format", "=", "'csr'", ",", "random_s...
Return a randomly sampled MarkovChain instance with n states, where each state has k states with positive transition probability. Parameters ---------- n : scalar(int) Number of states. k : scalar(int), optional(default=None) Number of states that may be reached from each state wit...
[ "Return", "a", "randomly", "sampled", "MarkovChain", "instance", "with", "n", "states", "where", "each", "state", "has", "k", "states", "with", "positive", "transition", "probability", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/markov/random.py#L15-L60
train
Returns a randomly sampled MarkovChain instance with n states where each state has k states with positive transition probability.
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/random.py
random_stochastic_matrix
def random_stochastic_matrix(n, k=None, sparse=False, format='csr', random_state=None): """ Return a randomly sampled n x n stochastic matrix with k nonzero entries for each row. Parameters ---------- n : scalar(int) Number of states. k : scalar(int), o...
python
def random_stochastic_matrix(n, k=None, sparse=False, format='csr', random_state=None): """ Return a randomly sampled n x n stochastic matrix with k nonzero entries for each row. Parameters ---------- n : scalar(int) Number of states. k : scalar(int), o...
[ "def", "random_stochastic_matrix", "(", "n", ",", "k", "=", "None", ",", "sparse", "=", "False", ",", "format", "=", "'csr'", ",", "random_state", "=", "None", ")", ":", "P", "=", "_random_stochastic_matrix", "(", "m", "=", "n", ",", "n", "=", "n", "...
Return a randomly sampled n x n stochastic matrix with k nonzero entries for each row. Parameters ---------- n : scalar(int) Number of states. k : scalar(int), optional(default=None) Number of nonzero entries in each row of the matrix. Set to n if not specified. sparse...
[ "Return", "a", "randomly", "sampled", "n", "x", "n", "stochastic", "matrix", "with", "k", "nonzero", "entries", "for", "each", "row", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/markov/random.py#L63-L103
train
Returns a randomly sampled n x n stochastic matrix with k nonzero entries for each row.
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/random.py
_random_stochastic_matrix
def _random_stochastic_matrix(m, n, k=None, sparse=False, format='csr', random_state=None): """ Generate a "non-square stochastic matrix" of shape (m, n), which contains as rows m probability vectors of length n with k nonzero entries. For other parameters, see `random...
python
def _random_stochastic_matrix(m, n, k=None, sparse=False, format='csr', random_state=None): """ Generate a "non-square stochastic matrix" of shape (m, n), which contains as rows m probability vectors of length n with k nonzero entries. For other parameters, see `random...
[ "def", "_random_stochastic_matrix", "(", "m", ",", "n", ",", "k", "=", "None", ",", "sparse", "=", "False", ",", "format", "=", "'csr'", ",", "random_state", "=", "None", ")", ":", "if", "k", "is", "None", ":", "k", "=", "n", "# m prob vectors of dimen...
Generate a "non-square stochastic matrix" of shape (m, n), which contains as rows m probability vectors of length n with k nonzero entries. For other parameters, see `random_stochastic_matrix`.
[ "Generate", "a", "non", "-", "square", "stochastic", "matrix", "of", "shape", "(", "m", "n", ")", "which", "contains", "as", "rows", "m", "probability", "vectors", "of", "length", "n", "with", "k", "nonzero", "entries", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/markov/random.py#L106-L142
train
Generate a random non - square stochastic 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/random.py
random_discrete_dp
def random_discrete_dp(num_states, num_actions, beta=None, k=None, scale=1, sparse=False, sa_pair=False, random_state=None): """ Generate a DiscreteDP randomly. The reward values are drawn from the normal distribution with mean 0 and standard deviation `scale`. Parameters ...
python
def random_discrete_dp(num_states, num_actions, beta=None, k=None, scale=1, sparse=False, sa_pair=False, random_state=None): """ Generate a DiscreteDP randomly. The reward values are drawn from the normal distribution with mean 0 and standard deviation `scale`. Parameters ...
[ "def", "random_discrete_dp", "(", "num_states", ",", "num_actions", ",", "beta", "=", "None", ",", "k", "=", "None", ",", "scale", "=", "1", ",", "sparse", "=", "False", ",", "sa_pair", "=", "False", ",", "random_state", "=", "None", ")", ":", "if", ...
Generate a DiscreteDP randomly. The reward values are drawn from the normal distribution with mean 0 and standard deviation `scale`. Parameters ---------- num_states : scalar(int) Number of states. num_actions : scalar(int) Number of actions. beta : scalar(float), optional(def...
[ "Generate", "a", "DiscreteDP", "randomly", ".", "The", "reward", "values", "are", "drawn", "from", "the", "normal", "distribution", "with", "mean", "0", "and", "standard", "deviation", "scale", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/markov/random.py#L145-L213
train
Generates a DiscreteDP from the given state - action pairs and random 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/robustlq.py
RBLQ.b_operator
def b_operator(self, P): r""" The B operator, mapping P into .. math:: B(P) := R - \beta^2 A'PB(Q + \beta B'PB)^{-1}B'PA + \beta A'PA and also returning .. math:: F := (Q + \beta B'PB)^{-1} \beta B'PA Parameters ---------- P :...
python
def b_operator(self, P): r""" The B operator, mapping P into .. math:: B(P) := R - \beta^2 A'PB(Q + \beta B'PB)^{-1}B'PA + \beta A'PA and also returning .. math:: F := (Q + \beta B'PB)^{-1} \beta B'PA Parameters ---------- P :...
[ "def", "b_operator", "(", "self", ",", "P", ")", ":", "A", ",", "B", ",", "Q", ",", "R", ",", "beta", "=", "self", ".", "A", ",", "self", ".", "B", ",", "self", ".", "Q", ",", "self", ".", "R", ",", "self", ".", "beta", "S1", "=", "Q", ...
r""" The B operator, mapping P into .. math:: B(P) := R - \beta^2 A'PB(Q + \beta B'PB)^{-1}B'PA + \beta A'PA and also returning .. math:: F := (Q + \beta B'PB)^{-1} \beta B'PA Parameters ---------- P : array_like(float, ndim=2) ...
[ "r", "The", "B", "operator", "mapping", "P", "into" ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/robustlq.py#L118-L153
train
r This function applies the B operator to the current state of the 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...
QuantEcon/QuantEcon.py
quantecon/robustlq.py
RBLQ.robust_rule
def robust_rule(self, method='doubling'): """ This method solves the robust control problem by tricking it into a stacked LQ problem, as described in chapter 2 of Hansen- Sargent's text "Robustness." The optimal control with observed state is .. math:: u_t ...
python
def robust_rule(self, method='doubling'): """ This method solves the robust control problem by tricking it into a stacked LQ problem, as described in chapter 2 of Hansen- Sargent's text "Robustness." The optimal control with observed state is .. math:: u_t ...
[ "def", "robust_rule", "(", "self", ",", "method", "=", "'doubling'", ")", ":", "# == Simplify names == #", "A", ",", "B", ",", "C", ",", "Q", ",", "R", "=", "self", ".", "A", ",", "self", ".", "B", ",", "self", ".", "C", ",", "self", ".", "Q", ...
This method solves the robust control problem by tricking it into a stacked LQ problem, as described in chapter 2 of Hansen- Sargent's text "Robustness." The optimal control with observed state is .. math:: u_t = - F x_t And the value function is :math:`-x'Px` ...
[ "This", "method", "solves", "the", "robust", "control", "problem", "by", "tricking", "it", "into", "a", "stacked", "LQ", "problem", "as", "described", "in", "chapter", "2", "of", "Hansen", "-", "Sargent", "s", "text", "Robustness", ".", "The", "optimal", "...
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/robustlq.py#L155-L212
train
This method solves the robust rule of the associated Riccati - specific state.
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/robustlq.py
RBLQ.robust_rule_simple
def robust_rule_simple(self, P_init=None, max_iter=80, tol=1e-8): """ A simple algorithm for computing the robust policy F and the corresponding value function P, based around straightforward iteration with the robust Bellman operator. This function is easier to understand but o...
python
def robust_rule_simple(self, P_init=None, max_iter=80, tol=1e-8): """ A simple algorithm for computing the robust policy F and the corresponding value function P, based around straightforward iteration with the robust Bellman operator. This function is easier to understand but o...
[ "def", "robust_rule_simple", "(", "self", ",", "P_init", "=", "None", ",", "max_iter", "=", "80", ",", "tol", "=", "1e-8", ")", ":", "# == Simplify names == #", "A", ",", "B", ",", "C", ",", "Q", ",", "R", "=", "self", ".", "A", ",", "self", ".", ...
A simple algorithm for computing the robust policy F and the corresponding value function P, based around straightforward iteration with the robust Bellman operator. This function is easier to understand but one or two orders of magnitude slower than self.robust_rule(). For more inform...
[ "A", "simple", "algorithm", "for", "computing", "the", "robust", "policy", "F", "and", "the", "corresponding", "value", "function", "P", "based", "around", "straightforward", "iteration", "with", "the", "robust", "Bellman", "operator", ".", "This", "function", "...
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/robustlq.py#L214-L261
train
A simple algorithm for computing the robust policy F and the value function P for the current key - value entry. This method is used to compute the robust policy F and the value function P for the current key - value entry.
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/robustlq.py
RBLQ.F_to_K
def F_to_K(self, F, method='doubling'): """ Compute agent 2's best cost-minimizing response K, given F. Parameters ---------- F : array_like(float, ndim=2) A k x n array method : str, optional(default='doubling') Solution method used in solving th...
python
def F_to_K(self, F, method='doubling'): """ Compute agent 2's best cost-minimizing response K, given F. Parameters ---------- F : array_like(float, ndim=2) A k x n array method : str, optional(default='doubling') Solution method used in solving th...
[ "def", "F_to_K", "(", "self", ",", "F", ",", "method", "=", "'doubling'", ")", ":", "Q2", "=", "self", ".", "beta", "*", "self", ".", "theta", "R2", "=", "-", "self", ".", "R", "-", "dot", "(", "F", ".", "T", ",", "dot", "(", "self", ".", "...
Compute agent 2's best cost-minimizing response K, given F. Parameters ---------- F : array_like(float, ndim=2) A k x n array method : str, optional(default='doubling') Solution method used in solving the associated Riccati equation, str in {'doubling...
[ "Compute", "agent", "2", "s", "best", "cost", "-", "minimizing", "response", "K", "given", "F", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/robustlq.py#L263-L290
train
Compute agent 2 s best cost minimizing response K given a given F.
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/robustlq.py
RBLQ.K_to_F
def K_to_F(self, K, method='doubling'): """ Compute agent 1's best value-maximizing response F, given K. Parameters ---------- K : array_like(float, ndim=2) A j x n array method : str, optional(default='doubling') Solution method used in solving t...
python
def K_to_F(self, K, method='doubling'): """ Compute agent 1's best value-maximizing response F, given K. Parameters ---------- K : array_like(float, ndim=2) A j x n array method : str, optional(default='doubling') Solution method used in solving t...
[ "def", "K_to_F", "(", "self", ",", "K", ",", "method", "=", "'doubling'", ")", ":", "A1", "=", "self", ".", "A", "+", "dot", "(", "self", ".", "C", ",", "K", ")", "B1", "=", "self", ".", "B", "Q1", "=", "self", ".", "Q", "R1", "=", "self", ...
Compute agent 1's best value-maximizing response F, given K. Parameters ---------- K : array_like(float, ndim=2) A j x n array method : str, optional(default='doubling') Solution method used in solving the associated Riccati equation, str in {'doublin...
[ "Compute", "agent", "1", "s", "best", "value", "-", "maximizing", "response", "F", "given", "K", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/robustlq.py#L292-L319
train
Compute agent 1 s best value - maximizing response F given a given K.
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/robustlq.py
RBLQ.compute_deterministic_entropy
def compute_deterministic_entropy(self, F, K, x0): r""" Given K and F, compute the value of deterministic entropy, which is .. math:: \sum_t \beta^t x_t' K'K x_t` with .. math:: x_{t+1} = (A - BF + CK) x_t Parameters --------...
python
def compute_deterministic_entropy(self, F, K, x0): r""" Given K and F, compute the value of deterministic entropy, which is .. math:: \sum_t \beta^t x_t' K'K x_t` with .. math:: x_{t+1} = (A - BF + CK) x_t Parameters --------...
[ "def", "compute_deterministic_entropy", "(", "self", ",", "F", ",", "K", ",", "x0", ")", ":", "H0", "=", "dot", "(", "K", ".", "T", ",", "K", ")", "C0", "=", "np", ".", "zeros", "(", "(", "self", ".", "n", ",", "1", ")", ")", "A0", "=", "se...
r""" Given K and F, compute the value of deterministic entropy, which is .. math:: \sum_t \beta^t x_t' K'K x_t` with .. math:: x_{t+1} = (A - BF + CK) x_t Parameters ---------- F : array_like(float, ndim=2) The po...
[ "r" ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/robustlq.py#L321-L357
train
r Compute the value of deterministic entropy which is given K and F and x0.
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/robustlq.py
RBLQ.evaluate_F
def evaluate_F(self, F): """ Given a fixed policy F, with the interpretation :math:`u = -F x`, this function computes the matrix :math:`P_F` and constant :math:`d_F` associated with discounted cost :math:`J_F(x) = x' P_F x + d_F` Parameters ---------- F : array_l...
python
def evaluate_F(self, F): """ Given a fixed policy F, with the interpretation :math:`u = -F x`, this function computes the matrix :math:`P_F` and constant :math:`d_F` associated with discounted cost :math:`J_F(x) = x' P_F x + d_F` Parameters ---------- F : array_l...
[ "def", "evaluate_F", "(", "self", ",", "F", ")", ":", "# == Simplify names == #", "Q", ",", "R", ",", "A", ",", "B", ",", "C", "=", "self", ".", "Q", ",", "self", ".", "R", ",", "self", ".", "A", ",", "self", ".", "B", ",", "self", ".", "C", ...
Given a fixed policy F, with the interpretation :math:`u = -F x`, this function computes the matrix :math:`P_F` and constant :math:`d_F` associated with discounted cost :math:`J_F(x) = x' P_F x + d_F` Parameters ---------- F : array_like(float, ndim=2) The policy fun...
[ "Given", "a", "fixed", "policy", "F", "with", "the", "interpretation", ":", "math", ":", "u", "=", "-", "F", "x", "this", "function", "computes", "the", "matrix", ":", "math", ":", "P_F", "and", "constant", ":", "math", ":", "d_F", "associated", "with"...
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/robustlq.py#L359-L402
train
Evaluates the policy function F and returns the matrix P_F and constant d_F associated with discounted cost F associated with discounted cost F.
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
docs/sphinxext/ipython_directive.py
EmbeddedSphinxShell.process_input_line
def process_input_line(self, line, store_history=True): """process the input, capturing stdout""" #print "input='%s'"%self.input stdout = sys.stdout splitter = self.IP.input_splitter try: sys.stdout = self.cout splitter.push(line) more = splitt...
python
def process_input_line(self, line, store_history=True): """process the input, capturing stdout""" #print "input='%s'"%self.input stdout = sys.stdout splitter = self.IP.input_splitter try: sys.stdout = self.cout splitter.push(line) more = splitt...
[ "def", "process_input_line", "(", "self", ",", "line", ",", "store_history", "=", "True", ")", ":", "#print \"input='%s'\"%self.input", "stdout", "=", "sys", ".", "stdout", "splitter", "=", "self", ".", "IP", ".", "input_splitter", "try", ":", "sys", ".", "s...
process the input, capturing stdout
[ "process", "the", "input", "capturing", "stdout" ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/docs/sphinxext/ipython_directive.py#L247-L260
train
process the input line capturing stdout
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
docs/sphinxext/ipython_directive.py
EmbeddedSphinxShell.process_image
def process_image(self, decorator): """ # build out an image directive like # .. image:: somefile.png # :width 4in # # from an input like # savefig somefile.png width=4in """ savefig_dir = self.savefig_dir source_dir = self.source_dir ...
python
def process_image(self, decorator): """ # build out an image directive like # .. image:: somefile.png # :width 4in # # from an input like # savefig somefile.png width=4in """ savefig_dir = self.savefig_dir source_dir = self.source_dir ...
[ "def", "process_image", "(", "self", ",", "decorator", ")", ":", "savefig_dir", "=", "self", ".", "savefig_dir", "source_dir", "=", "self", ".", "source_dir", "saveargs", "=", "decorator", ".", "split", "(", "' '", ")", "filename", "=", "saveargs", "[", "1...
# build out an image directive like # .. image:: somefile.png # :width 4in # # from an input like # savefig somefile.png width=4in
[ "#", "build", "out", "an", "image", "directive", "like", "#", "..", "image", "::", "somefile", ".", "png", "#", ":", "width", "4in", "#", "#", "from", "an", "input", "like", "#", "savefig", "somefile", ".", "png", "width", "=", "4in" ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/docs/sphinxext/ipython_directive.py#L262-L289
train
process an image and return the filename and the image directive
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
docs/sphinxext/ipython_directive.py
EmbeddedSphinxShell.process_input
def process_input(self, data, input_prompt, lineno): """Process data block for INPUT token.""" decorator, input, rest = data image_file = None image_directive = None #print 'INPUT:', data # dbg is_verbatim = decorator=='@verbatim' or self.is_verbatim is_doctest =...
python
def process_input(self, data, input_prompt, lineno): """Process data block for INPUT token.""" decorator, input, rest = data image_file = None image_directive = None #print 'INPUT:', data # dbg is_verbatim = decorator=='@verbatim' or self.is_verbatim is_doctest =...
[ "def", "process_input", "(", "self", ",", "data", ",", "input_prompt", ",", "lineno", ")", ":", "decorator", ",", "input", ",", "rest", "=", "data", "image_file", "=", "None", "image_directive", "=", "None", "#print 'INPUT:', data # dbg", "is_verbatim", "=", ...
Process data block for INPUT token.
[ "Process", "data", "block", "for", "INPUT", "token", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/docs/sphinxext/ipython_directive.py#L293-L362
train
Process the input block for INPUT token.
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
docs/sphinxext/ipython_directive.py
EmbeddedSphinxShell.process_output
def process_output(self, data, output_prompt, input_lines, output, is_doctest, image_file): """Process data block for OUTPUT token.""" if is_doctest: submitted = data.strip() found = output if found is not None: found = found.str...
python
def process_output(self, data, output_prompt, input_lines, output, is_doctest, image_file): """Process data block for OUTPUT token.""" if is_doctest: submitted = data.strip() found = output if found is not None: found = found.str...
[ "def", "process_output", "(", "self", ",", "data", ",", "output_prompt", ",", "input_lines", ",", "output", ",", "is_doctest", ",", "image_file", ")", ":", "if", "is_doctest", ":", "submitted", "=", "data", ".", "strip", "(", ")", "found", "=", "output", ...
Process data block for OUTPUT token.
[ "Process", "data", "block", "for", "OUTPUT", "token", "." ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/docs/sphinxext/ipython_directive.py#L365-L391
train
Process data block for OUTPUT token.
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
docs/sphinxext/ipython_directive.py
EmbeddedSphinxShell.process_pure_python
def process_pure_python(self, content): """ content is a list of strings. it is unedited directive conent This runs it line by line in the InteractiveShell, prepends prompts as needed capturing stderr and stdout, then returns the content as a list as if it were ipython code ...
python
def process_pure_python(self, content): """ content is a list of strings. it is unedited directive conent This runs it line by line in the InteractiveShell, prepends prompts as needed capturing stderr and stdout, then returns the content as a list as if it were ipython code ...
[ "def", "process_pure_python", "(", "self", ",", "content", ")", ":", "output", "=", "[", "]", "savefig", "=", "False", "# keep up with this to clear figure", "multiline", "=", "False", "# to handle line continuation", "fmtin", "=", "self", ".", "promptin", "for", ...
content is a list of strings. it is unedited directive conent This runs it line by line in the InteractiveShell, prepends prompts as needed capturing stderr and stdout, then returns the content as a list as if it were ipython code
[ "content", "is", "a", "list", "of", "strings", ".", "it", "is", "unedited", "directive", "conent" ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/docs/sphinxext/ipython_directive.py#L456-L533
train
This function processes the pure python code.
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
docs/sphinxext/ipython_directive.py
EmbeddedSphinxShell.process_pure_python2
def process_pure_python2(self, content): """ content is a list of strings. it is unedited directive conent This runs it line by line in the InteractiveShell, prepends prompts as needed capturing stderr and stdout, then returns the content as a list as if it were ipython code ...
python
def process_pure_python2(self, content): """ content is a list of strings. it is unedited directive conent This runs it line by line in the InteractiveShell, prepends prompts as needed capturing stderr and stdout, then returns the content as a list as if it were ipython code ...
[ "def", "process_pure_python2", "(", "self", ",", "content", ")", ":", "output", "=", "[", "]", "savefig", "=", "False", "# keep up with this to clear figure", "multiline", "=", "False", "# to handle line continuation", "multiline_start", "=", "None", "fmtin", "=", "...
content is a list of strings. it is unedited directive conent This runs it line by line in the InteractiveShell, prepends prompts as needed capturing stderr and stdout, then returns the content as a list as if it were ipython code
[ "content", "is", "a", "list", "of", "strings", ".", "it", "is", "unedited", "directive", "conent" ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/docs/sphinxext/ipython_directive.py#L535-L604
train
This function processes the pure python2 code.
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/lss.py
simulate_linear_model
def simulate_linear_model(A, x0, v, ts_length): r""" This is a separate function for simulating a vector linear system of the form .. math:: x_{t+1} = A x_t + v_t given :math:`x_0` = x0 Here :math:`x_t` and :math:`v_t` are both n x 1 and :math:`A` is n x n. The purpose of separa...
python
def simulate_linear_model(A, x0, v, ts_length): r""" This is a separate function for simulating a vector linear system of the form .. math:: x_{t+1} = A x_t + v_t given :math:`x_0` = x0 Here :math:`x_t` and :math:`v_t` are both n x 1 and :math:`A` is n x n. The purpose of separa...
[ "def", "simulate_linear_model", "(", "A", ",", "x0", ",", "v", ",", "ts_length", ")", ":", "A", "=", "np", ".", "asarray", "(", "A", ")", "n", "=", "A", ".", "shape", "[", "0", "]", "x", "=", "np", ".", "empty", "(", "(", "n", ",", "ts_length...
r""" This is a separate function for simulating a vector linear system of the form .. math:: x_{t+1} = A x_t + v_t given :math:`x_0` = x0 Here :math:`x_t` and :math:`v_t` are both n x 1 and :math:`A` is n x n. The purpose of separating this functionality out is to target it for ...
[ "r", "This", "is", "a", "separate", "function", "for", "simulating", "a", "vector", "linear", "system", "of", "the", "form" ]
26a66c552f2a73967d7efb6e1f4b4c4985a12643
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/lss.py#L20-L64
train
r Simulates a vector linear system of A.
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...