Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3459400
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:06:06+00:00 2026-05-18T10:06:06+00:00

I am new to Numpy and I would like to ask you how to

  • 0

I am new to Numpy and I would like to ask you how to calculate euclidean distance between points stored in a vector.

Let’s assume that we have a numpy.array each row is a vector and a single numpy.array. I would like to know if it is possible to calculate the euclidean distance between all the points and this single point and store them in one numpy.array.

Here is an interface:

points #2d list of row-vectors
singlePoint #one row-vector

listOfDistances= procedure( points,singlePoint)

Can we have something like this?
Or is it possible to have one command to have the single point as a list of other points and at the end we get a matrix of distances?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T10:06:07+00:00Added an answer on May 18, 2026 at 10:06 am

    While you can use vectorize, @Karl’s approach will be rather slow with numpy arrays.

    The easier approach is to just do np.hypot(*(points - single_point).T). (The transpose assumes that points is a Nx2 array, rather than a 2xN. If it’s 2xN, you don’t need the .T.

    However this is a bit unreadable, so you write it out more explictly like this (using some canned example data…):

    import numpy as np
    single_point = [3, 4]
    points = np.arange(20).reshape((10,2))
    
    dist = (points - single_point)**2
    dist = np.sum(dist, axis=1)
    dist = np.sqrt(dist)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to store and load numpy arrays from binary files. For that
I would like to ask a completely new question regarding this code . The
I am new to using numpy and one thing that I really don't understand
I am new to Python and Numpy, and I am facing a problem, that
I would like to append a value at the end of my numpy.array .
I'm new to NumPy and I'm trying to compute some simple statistics like the
I am new to python and numpy so please excuse me if this problem
I would like to add syntax to Jython to enable a nicer API for
I would like to write an image labeling tool using PyQT4: load a number
I am new to numpy and am trying to find a Pythonic :) way

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.