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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:05:36+00:00 2026-06-18T12:05:36+00:00

I am trying to understand the following code for image of logistic map,but I

  • 0

I am trying to understand the following code for image of logistic map,but I am stuck on the point where

ys = [ ]
rs = numpy.linspace(0, 4, 400) 

What does rs mean?
What i in range() mean?
I would really appreciate your help!

def f(x, r):
    """Discrete logistic equation with parameter r"""
    return r*x*(1-x)

if __name__ == '__main__':
    # initial condition for x
    ys = []
    rs = numpy.linspace(0, 4, 400)
    for r in rs:
        x = 0.1
        for i in range(500):
            x = f(x, r)

        for i in range(50):
            x = f(x, r)
            ys.append([r, x])

    ys = numpy.array(ys)
    pylab.plot(ys[:,0], ys[:,1], '.')
    pylab.show()
  • 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-06-18T12:05:36+00:00Added an answer on June 18, 2026 at 12:05 pm
    rs = numpy.linspace(0, 4, 400) 
    

    creates a numpy array with 400 values equal-spaced between 0 and 4 (including the end-points).

    Here are some smaller examples:

    In [17]: import numpy as np
    
    In [18]: np.linspace(0, 4, 5)
    Out[18]: array([ 0.,  1.,  2.,  3.,  4.])
    
    In [19]: np.linspace(0, 4, 10)
    Out[19]: 
    array([ 0.        ,  0.44444444,  0.88888889,  1.33333333,  1.77777778,
            2.22222222,  2.66666667,  3.11111111,  3.55555556,  4.        ])
    

    for i in range(50) is explained in the Python tutorial (section 4.2 and 4.3).


    Here are some comments to help explain the code.

    import numpy as np
    import matplotlib.pyplot as plt
    import pylab
    import numpy
    
    def f(x, r):
        """Discrete logistic equation with parameter r"""
        return r*x*(1-x)
    
    if __name__ == '__main__':
        # initial condition for x
        ys = []
        rs = numpy.linspace(0, 4, 400)
    
        # Loop through `rs`. `r` is assigned the values in `rs` one at a time. 
        for r in rs:
            x = 0.1
            # Repeat this loop 500 times. 
            # i is just a dummy variable since it is not used inside the for-loop.
            for i in range(500):
                # Evaluate f at (x, r). The return value is assigned to x.
                # x is then fed back into f(x, r). 
                # This makes x jump around 500 times according to the logistic equation.
                # r remains fixed.
                x = f(x, r)
    
            # Do this 50 times
            for i in range(50):
                # Again make the x jump around according to the logistic equation
                x = f(x, r)
                # Save the point (r, x) in the list ys
                ys.append([r, x])
    
        # ys is a list of lists.
        # You can also think of ys as a list of [r, x] point.
        # This converts the list of lists into a 2D numpy array.
        ys = numpy.array(ys)
    
        # ys[:,0] is a 1D array of r values
        # ys[:, 1] is a 1D array of x values
        # This draws a scatter plot of (r, x) points.
        pylab.plot(ys[:,0], ys[:,1], '.')
        pylab.show()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand the following 3 code statements involving pointers (through image
I am trying to understand the following code: #include<stdio.h> #include<stdlib.h> #include<sys/io.h> #define baseport 0x378
i am trying to understand following fragment of javascript code <!DOCTYPE html> <html> <body>
I was just trying to understand delegates using the following code. public class delegatesEx
I'm stuck trying to understand the following: %w[a b c d][4,20] => [] %w[a
I'm trying to understand why the following test does not fail. In this simplified
I'm trying to understand what it is about the following code that is perfectly
I've been trying to understand why the following code gives me a bad pointer
i'm struggling and trying to understand why the following code is not working. I
I'm trying to understand the following piece of code: lock_server::lock_server(class rsm *_rsm) { //code

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.