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 7069919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:30:15+00:00 2026-05-28T05:30:15+00:00

Is there an efficient way to resample a numpy array using zero-order hold? Ideally

  • 0

Is there an efficient way to resample a numpy array using zero-order hold? Ideally something with a signature like that of numpy.interp?

I’m aware of the scipy.interpolate.interp1d, but I’m sure that a vectorised alternative would be available for dealing with cases like this.

  • 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-28T05:30:15+00:00Added an answer on May 28, 2026 at 5:30 am

    Numpy < 1.12

    Since you won’t be interpolating any new values, the most efficient way would be to leave the original array as is and index it with floats. This is effectively a zero-order hold.

    >>> import numpy as np
    >>> A = np.array(range(10))
    >>> [A[i] for i in np.linspace(0, 9, num=25)]
    [0, 0, 0, 1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 9]
    

    Numpy >= 1.12

    Indexing with floats was deprecated in numpy v1.11 and removed in v1.12 (Jan 2017). The code shown above raises IndexError exception in current numpy versions.

    You can reproduce the float indexing behavior of older numpy versions by using a wrapper to access the array, converting float indices to integers on the fly. When memory efficiency is a concern, this would avoid the need to pre-emptively interpolate intermediate values using numpy.interp or scipy.interpolate.interp1d.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have many 100x100 grids, is there an efficient way using numpy to calculate
Is there an efficient way to take a subset of a C# array and
SQL Experts, Is there an efficient way to group runs of data together using
Is there a more efficient way to convert an HTMLCollection to an Array, other
Is there a more efficient way to clamp real numbers than using if statements
Is there an efficient way to scale a number of images so that they
Is there an efficient way to fill in pixels with a value of zero
Is there any efficient way to fetch texture data in a random way? That
If we have an array of integers, then is there any efficient way other
Is there an efficient way using sql server 2005 to remove all characters in

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.