Skip to content

Curve fitting to an arbitrary function #1081

Discussion options

You must be logged in to vote

Hello,

According to the signature of that function, it is expecting a func delegate that defines your function and which takes as input three double parameters and returns a double output value. Checking the class reference (found here and screenshotted below), we can see that the inputs are meant to be p0, p1, and x in that order.

Therefore, you can declare a Func type with the matching signature that performs the calculation defined by your function and then pass it to Curve.Fit().

In case you are unfamiliar with that feature of the C# language, you may do this using a lambda as I do in the code below. There are also a number of other ways such as defining a static function with the sam…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by jbCleverfield
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants