omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Non-linear curve fitting?

    Pythonista
    4
    6
    4431
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • mason
      mason last edited by

      Hey there, so I see that Pythonista has no access to SciPy which was the only way I knew how to do a non-linear curve fit in python. Do any of you know any way around this limitation? I'd really like to use my iPad for data analysis but this is holding me back.

      1 Reply Last reply Reply Quote 0
      • plessner
        plessner last edited by

        polyfit in the numpy module does fitting to a polynomial. There are other more specialized methods also in the numpy module.

        1 Reply Last reply Reply Quote 0
        • mason
          mason last edited by

          I'm aware of the polynomial fit, but I was hoping for something where I can specify some fit function like say a*e^(-x^2/b) where a and b are fit parameters. I can only find methods to do this with scipy. Do you know a method to do this on Pythonista?

          1 Reply Last reply Reply Quote 0
          • JonB
            JonB last edited by

            https://en.m.wikipedia.org/wiki/Levenberg–Marquardt_algorithm

            You have to manually compute the derivative wrt your free parameters at each x data point to form the jacobian matrix. For a simple example such as your function, you can analytically derive the jacobian (use sympy or pencil and paper).

            1 Reply Last reply Reply Quote 0
            • jmv38
              jmv38 last edited by jmv38

              lol i was about to write the same post...! Except i would rather compute the jacobian directly with a small increment.

              1 Reply Last reply Reply Quote 0
              • JonB
                JonB last edited by

                that is another option, and is certainly the better general solution for dealing with user defined functions.... , but since most of the cost is going to be computation of the jacobian, an analytic solution will be much faster. I tend to deal with very large problems, but for typical curve fitting it is probably adequate.

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post
                Powered by NodeBB Forums | Contributors