On Feb 21, 1:31 pm, Iwan Lappo-Danilewski <ivanjazz...@gmail.com>
wrote:
> What I'd like to have would be the data as a variables (something like
> "data = readdata('.dat');

the question is, what is .dat. if it is csv like, there are methods to
read it. depends on .dat! python is even able to read from xls.

> a,b = var('a b'); f(x) = a+ b*x;  a,b = fit
> (data,f,(a,b)); ffit(x) = a+ b*x ") ....
> Are there any attempts/
> scripts known that go into that direction?

there is a "find_fit" function, new since 3.2.1.

First we create some datapoints of a sine function with some random
perturbations:
sage: data = [(i, 1.2 * sin(0.5*i-0.2) + 0.1 * normalvariate(0, 1))
for i in xsrange(0, 4*pi, 0.2)]
sage: var('a, b, c, x')
(a, b, c, x)

We define a function with free parameters a, b and c:
sage: model(x) = a * sin(b * x - c)

We search for the parameters that give the best fit to the data:
sage: find_fit(data, model)
[a == 1.21..., b == 0.49..., c == 0.19...]


The benefits of using R as you mentioned is, that you get an analysis
about the linear or generalized linear model about the errors, amount
of "explanation" for each part of the fitted result, anova, and so on.
Plotting should be straight forward. Use the "solution_dict" parameter
if you want to use the result for substitutions.

h
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to