EngWiPy
- 1,361
- 61
Solving ##dy## yields to the following formula
dy = y\left[\frac{1}{1-y\,\delta}-1\right]
To have a positive increment ##dy## we need ##0<y\,\delta<1##. How to incorporate this in the calculation of ##dy##? In other words, what ##dy## should be when the condition is not met? Can we say
dy=\max\left[\rho,\,\frac{1}{1-y\,\delta}-1\right]
where ##\rho = 0.001##, for example? Also, I think we need to put some condition on ##dy## like ##0<dy<1##, right?
The code becomes (before applying the conditions on ##dy##)
but ##dy## sometimes becomes negative, and others very large positive (e.g., 1000)!
dy = y\left[\frac{1}{1-y\,\delta}-1\right]
To have a positive increment ##dy## we need ##0<y\,\delta<1##. How to incorporate this in the calculation of ##dy##? In other words, what ##dy## should be when the condition is not met? Can we say
dy=\max\left[\rho,\,\frac{1}{1-y\,\delta}-1\right]
where ##\rho = 0.001##, for example? Also, I think we need to put some condition on ##dy## like ##0<dy<1##, right?
The code becomes (before applying the conditions on ##dy##)
Python:
import math
K = 3
M = 2
dx = 0.01
delta = 0.01
y_Upper_lim = 7
#[1-FX(x)]^{(K-M)}
def F(x):
return math.exp(-x*(K-M))
#fX(x) or fY(y)
def f(u):
return math.exp(-u)
def G(z, m, x_prev_lim, y_current_lower_lim):
res = 0
#The lower limit of the integrations over x
ux = x_prev_lim
uy = y_current_lower_lim
dy = uy*((1/(1-uy*delta)) - 1)
while uy < y_Upper_lim:
while ux <= uy*z:
if m == M:
res += F(ux)*f(ux)*f(uy)*dx*dy
ux += dx
else:
res += G(z - (ux/uy), m+1, ux, z/ux)*f(ux)*f(uy)*dx*dy
ux += dx
uy += dy
return res
(math.factorial(K)/math.factorial(K-M))*G(1, 1, 0.0001, 0.0001)
but ##dy## sometimes becomes negative, and others very large positive (e.g., 1000)!
Last edited: