简体   繁体   中英

How to make to get a 2 parameter fit using a Non linear model fit in python

Hi I'm very new to python. I was tasked by my Pi to get a 2-parameter fit to an equation I'm using, using a non-linear model fit In python. He did the same but he used mathematica. I'm trying to recreate the same magic but in python. I've attached images 1 , 2 , 3 of what my PI did in Mathematica.

This is what i have so far. Im not asking for you to solve for me. Im asking for a guide

  Input = gam0 = 72.8;
  temp = 293.15 ;
  Input= gam[x2_] = gam0 - 0.0187 * temp * 'Natural logarithm[1+628.14*55.556*x2]';

To fix these lines you should write something like this:

import math
gam0 = 72.8
temp = 293.15
def gam(x2):
  return gam0 - 0.0187 * temp * math.log(1+628.14*55.556*x2)

I'm not familiar with Mathematica's syntax so this might not be 100% equivalent but the logic behind it is the same. What did I do?

  • remove input = , this is not Python syntax.
  • remove; at the end of the lines, this is also no Python syntax.
  • I think the last line of your code is a function in Mathematica (not 100%) sure, I rewrote this as a Python function.
  • Changed this 'Natural logarithm[1+628.14*55.556*x2]' to math.log(1+628.14*55.556*x2) to make it Python.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM