The problem is with Integral(Piecewise((0, Or(s_theta < 0, s_theta >
1)), (0.5*s_theta**(-0.5)*(0.1*s_theta + 2.5), True)), (s_theta, 0,
1)).

Aaron Meurer

On Sun, Dec 22, 2013 at 10:29 PM, Aaron Meurer <[email protected]> wrote:
> This looks like a bug.
>
> Aaron Meurer
>
> On Thu, Dec 19, 2013 at 5:16 PM, eTna <[email protected]> wrote:
>> Hi,
>>
>> Trying to write something with sympy for the first time... I'm stuck with
>> some error and not to sure which way to look. The code is fairly short: I
>> define a profit function, a cdf, and would like to compute the expected
>> profit for a range of prices, depending on some parameter's value:
>>
>> s_theta, s_p, s_p_bar, s_eta, s_gamma = symbols('s_theta s_p s_p_bar s_eta
>> s_gamma')
>>
>> 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 - 0.1)*(s_theta +
>> s_p**(-s_eta)), True))
>>
>> 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_expected_profit(Function):
>>   nargs = 4
>>
>>   @classmethod
>>   def eval(cls, s_p, s_p_bar, s_eta, s_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_theta, 0, 1))
>>
>> for gamma in [0.5, 0.7, 1.0]:
>>   x_axis = np.linspace(0.1, 2.0, int(round(((2.0-0.1)/0.1)))+1)
>>   ls_profits = [function_expected_profit(x, 2.0, 2.0, gamma) for x in
>> x_axis]
>>   plt.plot(x_axis, ls_profits, label = 'gamma = %s' %gamma)
>> legend = plt.legend(loc='upper right')
>> plt.show()
>>
>> The profit and cdf functions seem to work fine, the differentiation of the
>> cdf as well... but I can compute the expected profit only for gamma = 1.
>> Trying to compute the expected profit with gamma = 0.5, I get "ValueError:
>> Non-suitable parameters.".
>>
>> Many thanks for your time and sorry about the noobish question,
>>
>> 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.

-- 
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.

Reply via email to