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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:23:15+00:00 2026-06-15T18:23:15+00:00

Module OneDMaps: def LogisticMap(a,nIts,x): for n in xrange(0,nIts): return 4.*a*x*(1.-x) Actual Program: # Import

  • 0

Module OneDMaps:

def LogisticMap(a,nIts,x):
    for n in xrange(0,nIts):
        return 4.*a*x*(1.-x)

Actual Program:

# Import plotting routines
from pylab import *
import OneDMaps 

def OneDMap(a,N,x,f):
    return x.append(f(a,N,x))

# Simulation parameters
# Control parameter of the map: A period-3 cycle
a = 0.98
# Set up an array of iterates and set the initital condition
x = [0.1]
# The number of iterations to generate
N = 100

#function name in OneDMaps module
func = LogisticMap

# Setup the plot
xlabel('Time step n') # set x-axis label
ylabel('x(n)') # set y-axis label
title(str(func) + ' at r= ' + str(a)) # set plot title

# Plot the time series: once with circles, once with lines
plot(OneDMap(a,N,x,func), 'ro', OneDMap(a,N,x,func) , 'b')  

The program is supposed to call a function from a module OneDMaps.py and then plot it against it’s iterates. I get the error “Can’t multiply sequence by non-int of type float” and i’ve tried using LogisticMap(float(a)…) but that didn’t work. Also I want the function name to show up in the title of the plot but i get “at r=0.98 instead of it saying LogisticMap at r= 0.98.

  • 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-15T18:23:16+00:00Added an answer on June 15, 2026 at 6:23 pm

    You set up a list like this:

    x = [0.1]
    

    You then multipy it by a float:

    return 4.*a*x*(1.-x)
    

    You can’t do that. Perhaps you wanted x to be an array instead of a list?

    x = array([0.1])
    

    (That would do the multiplication elementwise)


    Note that adding lists concatenates:

    [0] + [1] == [0, 1]
    

    Multiplication by an integer is the same as concatenating that many times:

    [0] * 3 == [0, 0, 0]
    

    But that makes no sense for floats,

    [0] * 3.0 #raises TypeError as you've seen
    

    (what should you get if you multiply by 3.5 for example?)

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

Sidebar

Related Questions

plotting module def plotGraph(X,Y): fignum = random.randint(0,sys.maxint) plt.figure(fignum) ### Plotting arrangements ### return fignum
from module import * # adds 'BlahRenderer', 'FooRenderer', 'BarRenderer', etc. class MyClass def __init__(self,
A module that uses the spawn function from child-process module to call a program
No module named Crypto.Cipher when I try to import from Crypto.Cipher import AES My
In module MainClass.py which is in c:\MyProject\ModelClasses I'm trying import module MainHelper.py from c:\MyProject\Helpers
module Test def self.model_method puts this is a module method end end class A
Three module exists. Cfg, Main and Component Cfg.py value = 0 Component.py import Cfg
This module is part of a simple todo app I made with Python... def
test_module.rb module MyModule def module_func_a puts module_func_a invoked private_b end module_function :module_func_a private def
module MyModule def my_method; 'hello'; end end class MyClass class << self include MyModule

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.