Python Forum
Some help with some calculus and fish
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Some help with some calculus and fish
#1
Full disclosure, I've never taken calculus but I understand what I'm up against here. I need to return a list of values that represent the estimated weight of a fish on day n (index) based on the log of two inputs.

Growth from 35 to 258 g in 61 days yields the equation: ln(258) – ln(35) = tk
t is time in days; k is a rate constant (feed conversion ratio; lbs fed:lbs gained, which is not actually constant).

Anyway, this should end up with an inclined sigmoidal curve.

[Image: slide0019_image043.gif]

from math import log, exp

start_weight = 35
end_weight = 258
t = 61
# k = ?
# list comprehension
return [log(end_weight) - log(start_weight) for x in range(0, t)]  # some help here please
Here's my source document
Reply
#2
you dont have to reinvent the calculus theories

scikit-learn package has various machine learning algorithm readily available
http://scikit-learn.org/stable/

Apart from this use matplotlib package to plot any graphs

Using Pandas you can do all the mathematical calulations
Reply
#3
I'm not inventing any calculus.
I'm not doing machine learning.
I don't want to use external libraries in my environment. And I'm aware of scikit learn and matplot lib.
I'll be rendering in a browser with JS.
The workflow you described, while it may be the data science standard, is not the answer to the question I asked.
Reply
#4
Not sure i got your ask ?
You wanted a list of values in Array indexed by day... Python is zero indexed...
will you not have to add the weight incremented

from math import log, exp
start_weight = 35
end_weight = 258
t = 61
k = 0.033
# list comprehension

# Array Day indexed
weight_array = []

for x in range(0, t):
    interim_weigth = exp(log(start_weight)+ (k * x))
    weight_array.append(interim_weigth)

print(weight_array)  # some help here please
Reply
#5
The above doesn't quite work as expected when plotted. I've tried a bunch of variations on this and don't understand where I'm going wrong (which I feel pretty strongly is the calculus part).
[Image: HzDhue5.png]
This problem is better explained with a real-life formula for trout: start weight of 0.000285714 lbs, ending weight (250 days later) of 2 lbs with a k of 0.0356. This curve doesn't pass the smell test, but it's the same method.
[Image: HzDjY0B.png]

This would work better if I had read my own source. There's a crossover to linear after 61 days. Here's that curve (converted into pounds).

[Image: HzDwSS2.png]

Thanks for the help, I just needed to get out of my own way
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Calculus in python pythonforumrocks 13 13,866 Mar-24-2017, 04:10 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020