From d4366a5032a1987a3a8c26e1d52eb7200ebdaabb Mon Sep 17 00:00:00 2001 From: Henrique Alberti Date: Mon, 23 Oct 2023 09:38:58 -0300 Subject: [PATCH 1/2] Removing randomness from lqnash --- quantecon/_lqnash.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/quantecon/_lqnash.py b/quantecon/_lqnash.py index 2b2fbbbe0..e5815dc9d 100644 --- a/quantecon/_lqnash.py +++ b/quantecon/_lqnash.py @@ -4,7 +4,7 @@ def nnash(A, B1, B2, R1, R2, Q1, Q2, S1, S2, W1, W2, M1, M2, - beta=1.0, tol=1e-8, max_iter=1000, random_state=None): + beta=1.0, tol=1e-8, max_iter=1000): r""" Compute the limit of a Nash linear quadratic dynamic game. In this problem, player i minimizes @@ -67,7 +67,8 @@ def nnash(A, B1, B2, R1, R2, Q1, Q2, S1, S2, W1, W2, M1, M2, Random seed (integer) or np.random.RandomState or Generator instance to set the initial state of the random number generator for reproducibility. If None, a randomly initialized RandomState - is used. + is used. + Randomness is almost irrelevant because parameters are deterministically redefined Returns ------- From 8ceb1136a615272a3b865842d79037b4d1a09345 Mon Sep 17 00:00:00 2001 From: Daisuke Oyama Date: Sun, 22 Dec 2024 12:23:32 +0900 Subject: [PATCH 2/2] Replace random matrices with matrices with np.inf in lqnash --- quantecon/_lqnash.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/quantecon/_lqnash.py b/quantecon/_lqnash.py index e5815dc9d..ed32b2dd8 100644 --- a/quantecon/_lqnash.py +++ b/quantecon/_lqnash.py @@ -1,6 +1,5 @@ import numpy as np from scipy.linalg import solve -from .util import check_random_state def nnash(A, B1, B2, R1, R2, Q1, Q2, S1, S2, W1, W2, M1, M2, @@ -63,12 +62,6 @@ def nnash(A, B1, B2, R1, R2, Q1, Q2, S1, S2, W1, W2, M1, M2, This is the tolerance level for convergence max_iter : scalar(int), optional(default=1000) This is the maximum number of iteratiosn allowed - random_state : int or np.random.RandomState/Generator, optional - Random seed (integer) or np.random.RandomState or Generator - instance to set the initial state of the random number generator - for reproducibility. If None, a randomly initialized RandomState - is used. - Randomness is almost irrelevant because parameters are deterministically redefined Returns ------- @@ -106,13 +99,12 @@ def nnash(A, B1, B2, R1, R2, Q1, Q2, S1, S2, W1, W2, M1, M2, else: k_2 = B2.shape[1] - random_state = check_random_state(random_state) v1 = np.eye(k_1) v2 = np.eye(k_2) P1 = np.zeros((n, n)) P2 = np.zeros((n, n)) - F1 = random_state.standard_normal((k_1, n)) - F2 = random_state.standard_normal((k_2, n)) + F1 = np.full((k_1, n), np.inf) + F2 = np.full((k_2, n), np.inf) for it in range(max_iter): # update