示例#1
0
import model.utility as ut
import model.problem as pr

from helper.state import saver, loader
from helper.plotting import plt

l = AttrDict()

l.p = 25
l.n_true = 50000

# Continuous market distribution
R_true = NormalDistribution(8, 10)
X_true = [StudentTDistribution(ν=4)
          for _ in range(l.p)]  # EXᵢ = 0, Var(Xᵢ) = 1
l.M_true = synth.GaussianMarket(X_true,
                                R_true)  # constant corr(Xᵢ,R) = 1/p - ε

# Discretized sampled distribution in order to have real q⋆
X, R = l.M_true.sample(l.n_true)
l.M = synth.MarketDiscreteDistribution(X, R)

l.n_experiments = 100
l.λ = 3
l.δ = 0.2
l.ns = np.arange(25, 2025, 25)
l.Rf = 0

β = 1
r_threshold = 60
l.u = ut.LinearPlateauUtility(β, r_threshold)
示例#2
0
β = 1
r_threshold = 60
u = ut.LinearPlateauUtility(β, r_threshold)

Rf = 0

# In[6]:

print(ns)

# In[9]:

# True market
R_true = NormalDistribution(8, 10)
X_true = [1 / np.sqrt(2) * StudentTDistribution(ν=4) for _ in range(p)]
M_true = synth.GaussianMarket(X_true, R_true)

# Discretized market
X, R = M_true.sample(n_true)
M = synth.MarketDiscreteDistribution(X, R)

# In[10]:

# Real q∗ value computation
p_star = pr.Problem(X, R, λ=0, u=u)
p_star.solve()
q_star = p_star.q

# In[11]:

R_star_q_star = p_star.insample_cost(q_star)
示例#3
0
p = 10
n_true = 50000


def make_X():
    '''Returns list of bounded features with EXᵢ = 0 and Var[Xᵢ] = 1'''
    α = lambda: rn.uniform(0.1, 10)
    β = lambda: rn.uniform(0.1, 10)
    Xs = [KumaraswamyDistribution(α(), β()) for _ in range(p)]
    Xs = [(X - E(X)) / Std(X) for X in Xs]
    return Xs


R = NormalDistribution(8, 10)
X = make_X()
M = synth.GaussianMarket(X, R)

X, R = M.sample(n_true)
M = synth.MarketDiscreteDistribution(X, R)

X = DiscreteDistribution(X)
R = DiscreteDistribution(R)

n_experiments = 800
λs = np.arange(0, 13.2, 0.2)
n = 200
δ = 0.2
βs = [1, 0.99, 0.5, 0.1, 0.01]

for β in βs:
    u = ut.LinearPlateauUtility(β, 60)
示例#4
0

def make_X():
    '''Returns list of bounded features with EXᵢ = 0 and Var[Xᵢ] = 1'''
    α = lambda: rn.uniform(0.1, 10)
    β = lambda: rn.uniform(0.1, 10)
    Xs = [KumaraswamyDistribution(α(), β()) for _ in range(p_real)]
    Xs = [(X - E(X)) / Std(X) for X in Xs]
    return Xs


R = NormalDistribution(8, 10)
X = make_X()
corr_vect = np.zeros(p_real)
corr_vect[0] = 0.95
M = synth.GaussianMarket(X, R, corr_vect)

X, R = M.sample(n_true)
M = synth.MarketDiscreteDistribution(X, R)

X = DiscreteDistribution(X)
R = DiscreteDistribution(R)

n_experiments = 800
λ = 3
n = 500
δ = 0.2
# βs = [1,0.99,0.5,0.1,0.01]
βs = [1]
ps = range(1, p_real + 1)
# ps = [1]