Here is my code:
p = np.arange(0,1,0.01)
k = 1.5
# cost of the investment
c = 0.5
EW = (1.3-c)*p+(0.1-c)*(1-p)
EUW = ((-EW**(1.2-k)/(1-k)))**-1
and here is the error I'm getting:
:9: RuntimeWarning: invalid value encountered in power EUW = ((-EW**(1.2-k)/(1-k)))**-1
I am not sure why, this is the output of the EW array:
array([-0.4 , -0.388, -0.376, -0.364, -0.352, -0.34 , -0.328, -0.316, -0.304, -0.292, -0.28 , -0.268, -0.256, -0.244, -0.232, -0.22 , -0.208, -0.196, -0.184, -0.172, -0.16 , -0.148, -0.136, -0.124, -0.112, -0.1 , -0.088, -0.076, -0.064, -0.052, -0.04 , -0.028, -0.016, -0.004, 0.008, 0.02 , 0.032, 0.044, 0.056, 0.068, 0.08 , 0.092, 0.104, 0.116, 0.128, 0.14 , 0.152, 0.164, 0.176, 0.188, 0.2 , 0.212, 0.224, 0.236, 0.248, 0.26 , 0.272, 0.284, 0.296, 0.308, 0.32 , 0.332, 0.344, 0.356, 0.368, 0.38 , 0.392, 0.404, 0.416, 0.428, 0.44 , 0.452, 0.464, 0.476, 0.488, 0.5 , 0.512, 0.524, 0.536, 0.548, 0.56 , 0.572, 0.584, 0.596, 0.608, 0.62 , 0.632, 0.644, 0.656, 0.668, 0.68 , 0.692, 0.704, 0.716, 0.728, 0.74 , 0.752, 0.764, 0.776, 0.788])
I tried to add:
p = np.arange(0,1,0.01, dtype=complex)
which did help with the calculation and plotting the function, but this means that I can't use this to calculate optimal p values since the array is full of complex numbers. Is there an other way to go with this?