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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:11:46+00:00 2026-06-07T00:11:46+00:00

I am getting the following error when running my code: Typeerror: lambda() takes exactly

  • 0

I am getting the following error when running my code:

Typeerror: lambda() takes exactly 4 arguments (3 given)

Here is my code – my error is coming from the last line of code (I think) where I am trying to implement Scipy’s optimization algorithm fmin

from pylab import * 
import pylab as pl
from numpy import *
from scipy.optimize import fmin
from scipy import integrate
import numpy as np

def ode(s,t,k1,k2):
    A = s[0]
    B = s[1]
    C = s[2]
    dA = -k1*A
    dB = k1*A-k2*B
    dC = k2*B
    ds = [dA,dB,dC]
    return ds

def myllsq(teta,s0,t,s):
    y_obs = s
    k1 = teta[0]
    k2 = teta[1]
    s = integrate.odeint(ode,s0,t,args=(k1,k2))
    y_cal = s[:,1]
    lsq = sum(y_obs-y_cal)**2
    return lsq 

e = lambda teta,s0,t,s: myllsq(teta,s0,t,s)

if __name__ == '__main__': 
    n = 10
    tmin = 0.0
    tmax = 9
    k1 = 0.3
    k2 = 0.2
    s0 = [1,0,0]
    t = linspace(tmin,tmax,n)
    s = [0.000,0.416,0.489,0.595,0.506,0.493,0.458,0.394,0.335,0.309]
    teta = [k1,k2]
    print e(teta,s0,t,s)
    fmin(e,teta,args=(t,s),maxiter=10000,maxfun=10000)
  • 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-07T00:11:47+00:00Added an answer on June 7, 2026 at 12:11 am

    I think it should be something like:

    fmin(e,teta,args=(s0,t,s),maxiter=10000,maxfun=10000)
    

    instead of:

    fmin(e,teta,args=(t,s),maxiter=10000,maxfun=10000)
    

    You’re not passing the s0 list to your function.

    As a side note, there’s no real need for lambda here. You could just pass myllsq directly — e is just a less efficient version of myllsq.

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

Sidebar

Related Questions

I'm getting the error message when running the following code from a C# console
I'm trying to get http://www.gelens.org/code/gevent-websocket/ running and keep getting the following error. socket_id=1 already
I am getting the following error while running the code, Warning: require_once(product.php) [function.require-once]: failed
I am getting the following error when running my code in production. But the
I'm running some code through JSHint and I keep getting the following error: Don't
Hey getting the following error when running my MVP Entity Framework App : Keyword
I'm getting the following error when running brew doctor: Error: Your Cellar and TEMP
I am getting the following error while running my MVC application, which uses the
I'm getting the following error when running warble under both jRuby 1.3 and 1.4.
I am getting the following error after running git svn rebase: 'update-index --refresh: command

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.