RuntimeWarning: overflow encountered in long_scalars in formula - numpy

I am running this numpy financial function, and the calculation is throwing up the above error. How do I adjust this formula?
payment = (numpy.pmt(rate, term, -1 * current balance, future target balance, 0)) * -1
Thanks.
I tried using numpy.float64.pmt but can't figure out where in the formula to insert the dtype

Related

pine script sum function returns only float I need integer

I made simple variable
and i want to count how many times it occur
so I made code like this
a = close>open(it is just examplary, not my real code)
gross = ~~~~~~
num = cum(a ? 1 : 0)
total = sum(a ? gross : na, num)
I put the num variable into length position of sum function
but it turns error message like this
cannot call 'sum' with 'length'=series[float]. the argument should be of type: series[integer];
so to check the value of num is float, I made plot(num,~~) and it returns 128.0000
I think condition a occured 128times.
so the value of num isn't float am i right?
I don't know why error message happens
I already used round() and `int()
please help me solve this problem

Percentile calculation in HIVE

How can I calculate 25 percentile in Hive using sql. Let's say there is category, sub category and sales column. So how can I calculate the 25 percentile of sales? I tried to use the percentile(sales, 0.25) in hive but it is throwing an error:
Error while compiling statement: FAILED: NoMatchingMethodException No matching method for class org.apache.hadoop.hive.ql.udf.UDAFPercentile with (double, decimal(2,2)). Possible choices: FUNC(bigint, array) FUNC(bigint, double)
Documentation says:
A true percentile can only be computed for integer values. Use
PERCENTILE_APPROX if your input is non-integral.
Use percentile_approx for non-integral values. percentile_approx(DOUBLE col, p [, B]) - Returns an approximate pth percentile of a numeric column (including floating point types) in the group. The B parameter controls approximation accuracy at the cost of memory. Higher values yield better approximations, and the default is 10,000. When the number of distinct values in col is smaller than B, this gives an exact percentile value.

How can I use a CVX variable in a Numpy product that is to be Minimized?

I'm trying to optimize a configuration X (boolean), such that the total price : base_price + discount, on a configuration is minimized, but the problem formulation gives a Matmul error since x is a cvxpy Variable and thus doesn't conform to the Numpy shape even though it was defined with the correct length.
n = len(Configuration)
x = cp.Variable(n, boolean=True)
problem = cp.Problem(cp.Minimize(base_price + price#(price_rules_A#x <= price_rules_B)), [
config_rules_A#x <= config_rules_B,
config_rules_2A#x == config_rules_2B
])
# where price#(price_rules_A#x <= price_rules_B) is the total discount
# and price, price_rules_A and price_rules_B are numpy arrays
The error i get is
ValueError: matmul: Input operand 1 does not have enough dimensions (has 0, gufunc core with signature (n?,k),(k,m?)->(n?,m?) requires 1)
I expect it to find an optimal config for x ( 0010110...) such that the discount is minimized but it doesn't. Any idea what might be causing this?
Assuming the evaluation of the inequality in the objective function is suppose to work as index to price, you can rewrite the function as
cp.Minimize(base_price + price#(1-(price_rules_B - price_rules_A#x))
Then the elements in price where the inequality is true will be summed.

Removing multiplicative seasonality and trend from observations using Prophet?

I've fitted Prophet with logistic growth and multiplicative seasonality over time series data (daily observations spanning several years, no additional regressors; just ds, y) and have the forecast dataframe. How do I use the values from forecast to remove seasonality?
Within forecast, I acknowledge the weekly and yearly columns deal with seasonality on a weekly/yearly basis, and multiplicative_terms deals with changing magnitudes over time; but I don't know how to put this together to remove seasonality form my data.
I have the following possibly ways about attempting to remove seasonality, but believe what I'm doing is wrong.
#R
df$y - forecast$trend * forecast$multiplicative_terms * forecast$weekly * forecast$yearly
For reference, when using seasonal_decompose, I've had to use the following to get rid of seasonality; this doesn't hold for Prophet because of the additional terms.
#Python
df.y - trend* decomposition.seasonal
Edit- After doing a bit of research, I'm currently running this which looks right, but I was wondering if anyone can confirm whether this is the correct way to remove seasonality + trend?
df$y -
(forecast$trend +
(forecast$trend * forecast$weekly) +
(forecast$trend * forecast$yearly) +
(forecast$trend * forecast$multiplicative_terms)
)

Does Round(0.005) give a wrong result?

When I enter
Debug.Print(Round(0.005, 2))
0
in the Immediate Window in VBA (Excel 2010) I get 0 as a result. I would have expected 0.01.
I cannot imagine VBA calculating wrong so what am I doing wrong?
a bankers rounding vs arithmetic rounding thing
= Round(variable + 0.000001, 0)