Hi,
Sorry about what must be a silly question but I struggle a bit and I'm
pretty sure that a small hint will help a lot. I'm trying to compute an
expected profit after having defined two functions, one being the profit,
the other being the cdf. The last step involves integrating the product of
the profit and the derivative of the cdf over its interval and this is
where I'm stuck:
class function_cdf_theta(Function):
nargs = 2
@classmethod
def eval(cls, s_theta, s_gamma):
return Piecewise((0, s_theta < 0), (1, s_theta > 1), (s_theta**s_gamma,
True))
class function_profit(Function):
nargs = 4
@classmethod
def eval(cls, s_theta, s_p, s_p_bar, s_eta):
return Piecewise((0, s_p > s_p_bar), (s_p*(s_theta + s_p**(-s_eta)),
True))
class function_expected_profit(Function):
nargs = 4
@classmethod
def eval(cls, s_p, s_p_bar, s_eta, gamma):
return integrate(function_profit(s_theta, s_p, s_p_bar, s_eta)*\
diff(function_cdf_theta(s_theta, s_gamma), s_theta),
(s_gamma, 0, 1))
E.g.
>>> function_expected_profit(1, 2, 1.5, 1)
Piecewise((0, Or(s_theta < 0, s_theta > 1)), (Piecewise((Piecewise((0,
Or(s_theta < 0, s_theta > 1)), (Piecewise(((s_theta + 1)/(2*s_theta),
s_theta**2*log(s_theta)**3 == 0), ((s_theta**2*log(s_theta)**2 -
s_theta**2*log(s_theta) + s_theta*log(s_theta)**2 -
s_theta*log(s_theta))/(s_theta*log(s_theta)**3), True)), True)),
s_theta**2*log(s_theta)**3 == 0), (Piecewise((-(-s_theta**2*log(s_theta) -
s_theta*log(s_theta))/(s_theta**2*log(s_theta)**3), Or(s_theta < 0, s_theta
> 1)), (Piecewise(((s_theta + 1)/(2*s_theta), s_theta**2*log(s_theta)**3 ==
0), ((s_theta**2*log(s_theta)**2 - s_theta**2*log(s_theta) +
s_theta*log(s_theta)**2 - s_theta*log(s_theta))/(s_theta*log(s_theta)**3),
True)) - (-s_theta**2*log(s_theta) -
s_theta*log(s_theta))/(s_theta**2*log(s_theta)**3), True)), True)), True))
It's clear that function is not evaluated as it should be... I've tried to
play around with subs and stuffs like that but not been too successful so
far, so if anyone can tell me where to look that would be very appreciated.
Many thanks for your time and kindness,
Etienne
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
For more options, visit https://groups.google.com/groups/opt_out.