Search code examples
pythonvectorformulasimilaritydot-product

Nudge vector X towards/away vector A


I have :

d1 = np.dot(a,x)

the question is what formula I can use to modify X, so that :

d2 = d1 + delta

where "delta" is a parameter/number, specified by me.

In addition as a second case "delta" could be (d1*percent)


I'm looking for 'F' :

x1 = x * F 

so that :

d2 = np.dot(a,x1)

said otherwise :

d1 + delta = np.dot(a, x * F)

what is 'F' ?


kewl ;)

@staticmethod
def nudge(a,b,delta):
    d = hrr.dot(a, b)
    return b * ((d+delta)/d)


In [144]: hrr.dot(a,b)                                                                                                                                                       
Out[144]: 0.03531923115430759

In [145]: hrr.dot(a,hrr.nudge(a,b,0.1))                                                                                                                                      
Out[145]: 0.13531923115430755

In [146]: hrr.dot(a,hrr.nudge(a,b,0.2))                                                                                                                                      
Out[146]: 0.2353192311543074

Solution

  • I assume that np.dot(a,x) is the dot product of a and x

    F = (d1 + delta)/d1