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

  • Home
  • SEARCH
  • 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 929509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:11:03+00:00 2026-05-15T20:11:03+00:00

I have the following numpy array: # A B C Y my_arr = np.array([

  • 0

I have the following numpy array:

#                      A    B    C         Y
my_arr = np.array([ [.20, .54, .26],     # <0
                    [.22, .54, .24],     # 1
                    [.19, .56, .25],     # 2
                    [.19, .58, .23],     # 3
                    [.17, .62, .21] ])   # 4+

if a user enters a y (example, 2.5) I should out put three values, one for A, B, and C:

in my example A: .19, B: .57, C: .24

More Examples:

Y     A      B      C
0.2   .20    .54    .26 
1.5   .215   .55    .245
4.0   .17    .62    .21
8.7   .17    .62    .21

The user will enter a multiple of y values as a numpy array. the result should be an array as well

I’ve done bits and pieces of the code for example

#boundaries:
y[y < 0] = 0
y[y > 4] = 4

I’m also assuming that scipy.ndimage / map_coordinates will best fit my requirements rather than scipy.interpolate but I could be wrong

  • 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-15T20:11:03+00:00Added an answer on May 15, 2026 at 8:11 pm
    from scipy import array, ndimage
    
    #              A    B    C         Y
    m = array([ [.20, .54, .26],     # 0
                [.22, .54, .24],     # 1
                [.19, .56, .25],     # 2
                [.19, .58, .23],     # 3
                [.17, .62, .21] ])   # 4
    
    inputs = array([-1, 0, 0.2, 1, 1.5, 2, 2.5, 3, 4, 8.7])
    inputs[inputs < 0] = 0
    inputs[inputs > 4] = 4
    
    for y in inputs:
        x = ndimage.map_coordinates(m, [y * numpy.ones(3), numpy.arange(3)], order=1)
        print y, x
    

    >>> 
    0.0 [ 0.2   0.54  0.26]
    0.0 [ 0.2   0.54  0.26]
    0.2 [ 0.204  0.54   0.256]
    1.0 [ 0.22  0.54  0.24]
    1.5 [ 0.205  0.55   0.245]
    2.0 [ 0.19  0.56  0.25]
    2.5 [ 0.19  0.57  0.24]
    3.0 [ 0.19  0.58  0.23]
    4.0 [ 0.17  0.62  0.21]
    4.0 [ 0.17  0.62  0.21]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 505k
  • Answers 505k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer As in all statistics your answer will depend on what… May 16, 2026 at 3:29 pm
  • Editorial Team
    Editorial Team added an answer Your C#/VB.NET/... code is compiled to MSIL (CIL) The MSIL… May 16, 2026 at 3:29 pm
  • Editorial Team
    Editorial Team added an answer When you add the following mapping: routes.MapRoute("hierarchy", "{action}/{*url}" new {… May 16, 2026 at 3:29 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Let's say I have a 2D Numpy array: >>> a = np.random.random((4,6)) and I
I have a program which needs to turn many large one-dimensional numpy arrays of
I generate a list of one dimensional numpy arrays in a loop and later
I have a master array of length n of id numbers that apply to
I am trying to convert a PIL image into an array using NumPy. I
The following program loads two images with PyGame, converts them to Numpy arrays, and
I want to get the index of the min value of a numpy array
Have following setup: MainActivity class - extends activity MyLayout class - extends View Prefs
I have following string: <div> text0 </div> prefix <div> text1 <strong>text2</strong> text3 </div> text4
I have following page <html> <head> <script type=text/javascript src=e01.js></script> </head> <body> <script type=text/javascript> var

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.