will help you If you don't have to use 'numpy', then you can use the following code: code :
x=[17,13,12,15,16,14,16,16,18,19]
y=[94,73,59,80,93,85,66,79,77,91]
def X_bar_y_bar(x,y):
xave = sum(x)/float(len(x))
yave = sum(y)/float(len(y))
for i in range(len(x)):
result=((x[i]xave)*(y[i]yave))
print("{:.2f}".format(result))
X_bar_y_bar(x,y)
Share :

Multiply row with above row and obtain an average
By : MagicJane
Date : March 29 2020, 07:55 AM
wish helps you I have an excel table with lets say 500 columns and 2 rows. I want to multiply each cell in the second row with the cell above, in the first row. Then get the average of the sum. , For data in rows 1 and 2 use code :
=SUMPRODUCT(1:1,2:2)/COUNT(1:1)

google sheet custom function to multiply columns
By : JDuc38
Date : March 29 2020, 07:55 AM
will be helpful for those in need for the recommendation, but that didn't work unfortunately. The reason I'm not using the arrayformula function is because this is actually a small piece of a larger, more complicated function. What did end up working is pushing the "multiply" variable into newData as an array by putting it in brackets. code :
function myFunction() {
var sheet = SpreadsheetApp.getActive().getSheetByName("Sheet1");
var data = sheet.getRange("A1:B22").getValues();
var newData = []
for (i in data){
var row = data[i];
var multiply = row[0] * row[1]
newData.push([multiply])
Logger.log(newData)
}
sheet.getRange(1,3,22,1).setValues(newData)
}

Multiply the outputs custom loss function
By : Nicolas
Date : March 29 2020, 07:55 AM
Hope this helps I'm not sure if I'm understanding correctly, but I'll try. The loss function must contain both the predicted and the actual data  it's a way to measure the error between what your model is predicting and the true data. However, the predicted and actual data do not need to be onedimensional. You can make y_pred a tensor that contains both y_pred1 and y_pred2. Likewise, y_true can be a tensor that contains both y_true1 and y_true2. code :
import keras.backend as K
def my_loss(y_true, y_pred):
# this example is mean squared error
# works if if y_pred and y_true are greater than 1D
return K.mean(K.square(y_pred  y_true))
def my_loss(y_true, y_pred):
# calculate mean(abs(y_pred1*y_pred2  y_true1*ytrue2))
# this will work for 2D inputs of y_pred and y_true
return K.mean(K.abs(K.prod(y_pred, axis = 1)  K.prod(y_true, axis = 1)))
from keras import Model
from keras.layers import Input, Dense
from keras.layers import Concatenate
input_layer = Input(shape=(n, ))
shared = Dense(32)(input_layer)
sub1 = Dense(16)(shared)
sub2 = Dense(16)(shared)
y1 = Dense(1, activation='sigmoid')(sub1)
y2 = Dense(4, activation='softmax')(sub2)
mergedOutput = Concatenate()([y1, y2])
from keras import losses
def my_loss(y_true, y_pred):
final_loss = (losses.binary_crossentropy(y_true[:, 0], y_pred[:, 0]) +
y_true[:, 0] *
losses.categorical_crossentropy(y_true[:, 1:], y_pred[:,1:]))
return final_loss
model.compile(optimizer='adam', loss=my_loss)

I can't write a python average function that will average 3 input integers from user. (average has to be in float)
By : Lukas
Date : March 29 2020, 07:55 AM

writing a recursive function to multiply 2 integers, with a twist
By : Kojak.M.S
Date : March 29 2020, 07:55 AM
I wish this helpful for you You should step through this by hand with a simple multiplication, such as 2*1… you'll probably see that the problem is in a = add(a, b);. a*b is a+a+a+a+… until you have b total terms of a. Your routine is adding b in when it should only be decrementing b (which is effectively an addition counter). To set this up as a recursive routine, you're actually going to need a 3rd parameter… something to store the value to be added, so you can a = add(a, original_a);  the original_a should not be modified throughout the operation.

