I have two high-dimensional points (for this example let's consider 5 dimensional).
p0 = [2 4 1 3 9]
p1 = [5 2 1 0 8]
I want to fit a line (hyperplane) between them and then sample a random point (p2) from the line that is between the two original points. p2 is not necessarily the midpoint between the two points, but anywhere along the line. The image below shows what that would look like in 2-dimesions. How would I do that in python? Thanks!

You can parametrize this line segment as
p2 = p0 + t*(p1-p0)with parametertin range[0, 1].Doing this in code:
Note that
np.random.rand()selects from range[0, 1), so there is some small chance forp2 == p0.