In this section, we use simulations to evaluate the performance of the proposed LyDROO algorithm. All the computations are evaluated on a TensorFlow 2.0 platform with an Intel Core i5-4570 3.2GHz CPU and 12 GB of memory. We assume that the average channel gain h ̄i ̄ 3×108 de follows a path-loss model hi = Ad 4πfcdi , i = 1,··· ,N, where Ad = 3 denotes the antenna gain, fc = 915 MHz denotes the carrier frequency, de = 3 denotes the path loss exponent, and di in meters denotes the distance between the ith WD and the ES. hi follows an i.i.d. Rician distribution with line-of-sight link gain equal to 0.3h ̄ i . The noise power N0 = W υ0 with noise power spectral density υ0 = −174 dBm/Hz. Unless otherwise stated, we consider N = 10 WDs equally spaced with di = 120+15(i−1), for i = 1,··· ,N. The weight ci = 1.5 if i is an odd number and ci = 1 otherwise. The task data arrivals of all the WDs follow exponential distribution with equal average rate E [Ati ] = λi , i = 1, · · · , N . The values of the other parameters are listed in Table I, which are equal for all the WDs.,列出变量和他们怎么获得的
时间: 2024-02-15 15:27:27 浏览: 22
变量及其获取方式如下:
- h ̄i:平均信道增益。根据论文中所述的路径损耗模型,通过距离di计算得到。
- hi:第i个无线设备(WD)与边缘服务器(ES)之间的信道增益。根据论文中所述的路径损耗模型,通过距离di计算得到。
- N0:噪声功率。根据噪声功率谱密度和带宽W计算得到。
- υ0:噪声功率谱密度。根据论文中所述的参数值得到。
- ci:第i个无线设备(WD)的权重。根据论文中所述的规则计算得到。
- Ati:第i个无线设备(WD)到达的任务数据数量。根据论文中所述的规则,所有无线设备的任务数据到达率均相等。
- λi:第i个无线设备(WD)的任务数据到达率。根据论文中所述的规则,所有无线设备的任务数据到达率均相等。
- Ad:天线增益。根据论文中所述的参数值得到。
- fc:载波频率。根据论文中所述的参数值得到。
- de:路径损耗指数。根据论文中所述的参数值得到。
- di:第i个无线设备(WD)与边缘服务器(ES)之间的距离。根据论文中所述的规则计算得到。
- W:带宽。根据论文中所述的参数值得到。
- vu:信道噪声的方差。根据论文中所述的参数值得到。
这些参数的具体值和计算方式均在论文中给出。
相关问题
implement the UCB algorithm and plot the expected regret as a function of 𝑇 using 1000 sample path simulations with python
好的,我来给您提供一个Python实现UCB算法并绘制期望遗憾的代码示例。请注意,此处的期望遗憾是相对于最优选择而言的遗憾,即最优选择的累计收益减去算法的累计收益。
```
import math
import random
import matplotlib.pyplot as plt
# UCB算法函数
def ucb1(n, k, t):
if n == 0:
return float('inf')
return (k / n) + math.sqrt(2 * math.log(t) / n)
# 数据集
data = [0.1, 0.5, 0.8, 0.9, 0.3]
# 总的尝试次数
total_try = 1000
# 记录每个数据的尝试次数
try_nums = [0, 0, 0, 0, 0]
# 记录每个数据的得分
scores = [0, 0, 0, 0, 0]
# 最优选择的收益
optimal_reward = max(data) * total_try
# 模拟1000次实验
regrets = []
for i in range(1, 1001):
# 选择数据
idx = -1
max_score = -1
for j in range(len(data)):
score = ucb1(try_nums[j], scores[j], i)
if score > max_score:
max_score = score
idx = j
# 获取数据并计算得分
value = random.binomial(1, data[idx])
try_nums[idx] += 1
scores[idx] += (value - scores[idx]) / try_nums[idx]
# 计算累计收益和期望遗憾
cumulative_reward = sum(scores)
expected_regret = optimal_reward - cumulative_reward
regrets.append(expected_regret)
# 绘制期望遗憾随时间的变化曲线
plt.plot(range(1, 1001), regrets)
plt.xlabel('Time')
plt.ylabel('Expected Regret')
plt.show()
```
这段代码实现了UCB算法并绘制了期望遗憾随时间的变化曲线。其中,`data`表示数据集,`total_try`表示总的尝试次数,`try_nums`记录每个数据的尝试次数,`scores`记录每个数据的得分,`optimal_reward`表示最优选择的收益。在每次实验中,我们选择UCB值最大的数据进行尝试,并计算累计收益和期望遗憾。最终,我们绘制出所有实验的期望遗憾随时间的变化曲线。
use python to finish this task.please show me the code 1) Replicate the same numerical experiments as the examples for pricing barrier option in the PPTs.
Sure, here is the Python code to replicate the numerical experiments for pricing barrier options:
```python
import numpy as np
from scipy.stats import norm
# Parameters
S0 = 100.0 # initial stock price
K = 100.0 # strike price
T = 1.0 # time to maturity
r = 0.05 # risk-free rate
sigma = 0.2 # volatility
H = 90.0 # barrier level
# Simulation settings
M = 100000 # number of Monte Carlo simulations
N = 100 # number of time steps
# Time and step size
dt = T / N
t = np.linspace(0, T, N+1)
# Simulate stock prices
Z = np.random.standard_normal((M, N))
S = np.zeros((M, N+1))
S[:, 0] = S0
for i in range(N):
S[:, i+1] = S[:, i] * np.exp((r - 0.5*sigma**2)*dt + sigma*np.sqrt(dt)*Z[:, i])
# Compute option payoff
C = np.maximum(S[:, -1]-K, 0)
# Compute option price using Monte Carlo simulation
discount_factor = np.exp(-r*T)
option_price = discount_factor * np.mean(C)
print("Option price:", option_price)
# Compute barrier option payoff
B = np.all(S[:, :-1] > H, axis=1) * (S[:, -1] - K)
# Compute barrier option price using Monte Carlo simulation
barrier_option_price = discount_factor * np.mean(B)
print("Barrier option price:", barrier_option_price)
# Compute option delta using finite difference method
delta = np.zeros(N+1)
delta[0] = norm.cdf((np.log(S0/K) + (r + 0.5*sigma**2)*T) / (sigma*np.sqrt(T)))
for i in range(1, N+1):
Si = S[:, i]
Si_minus_1 = S[:, i-1]
Ci = np.maximum(Si-K, 0)
Ci_minus_1 = np.maximum(Si_minus_1-K, 0)
delta[i] = np.mean((Ci - Ci_minus_1) / (Si - Si_minus_1)) * np.exp(-r*dt)
print("Option delta:", delta[-1])
```
This code replicates the pricing of a vanilla European call option and a barrier option with a down-and-out feature. The code uses Monte Carlo simulation to estimate the option prices and the option delta, and it also uses the finite difference method to estimate the option delta. The results should match the ones shown in the PPTs.