Andreas Madsen

55 Reputation

7 Badges

10 years, 132 days

MaplePrimes Activity


These are replies submitted by Andreas Madsen

A more stable 2D math editor, its been an issue for many years but in Maple 17 it became much worse. Example: http://tinypic.com/r/2qd5uzl/8

On my Mac I can't install the update, it just shows this (and the Next button can't be clicked):

This issue happens both when Downloading via Maple and from the Website.

I found the issue, i missed a y1''(t), however now I'm back to the old issue, it just keep evaluation and never stops.

spring_ODE_setup.mw

I found the issue, i missed a y1''(t), however now I'm back to the old issue, it just keep evaluation and never stops.

spring_ODE_setup.mw

I have fixed the issues. But now I get a new error:

> dsolve({isc, ode});
Error, (in dsolve) found the following equations not depending on the unknowns of the input system: {y1(0) = F/k1, ((D@@2)(y1))(0) = 0}
spring_ODE_setup.mw

I have fixed the issues. But now I get a new error:

> dsolve({isc, ode});
Error, (in dsolve) found the following equations not depending on the unknowns of the input system: {y1(0) = F/k1, ((D@@2)(y1))(0) = 0}
spring_ODE_setup.mw

@epostma 

Thanks Erik

With your help I think I have created a procedure there allow me to calculate a R^2 or Pseudo-R^2 in almost any cases.
It looks like this:

Rsquared := proc (fnType::string, inFormular, X::{array, list, rtable}, inY::{array, list, rtable}, T::symbol)
  local N, Y, formular, ssRes, ssTotal;
  N := ArrayTools:-NumElems(inY):
  Y := inY:
  formular := inFormular:
  if (fnType = "exp" or fnType = "exponential" or fnType = "power") then
    Y := map(ln, Y):
    formular := ln(formular):
  end if;
  ssRes := add((Y[i]-(eval(formular, T = X[i])))^2, i = 1 .. N):
  ssTotal := N*Statistics:-CentralMoment(Y, 2):
  return evalhf(1-ssRes/ssTotal);
end proc:

And is used this way:
X := <seq(i, i = 1 .. 20)>;
Y := <0.07, 2, .16, .24, .36, .5, .8, 1.2, 1.8, 8, 4, 6, 9, 15, 20, 30, 43, 66.9, 100, 150>;
fitFn := ExponentialFit(X, Y, x);
R^2 = Rsquared("exp", fitFn, X, Y, x);

Since this is my first question in mapleprimes.com I don't know how to mark this tread answered – if I need to do so.

@epostma 

Thanks Erik

With your help I think I have created a procedure there allow me to calculate a R^2 or Pseudo-R^2 in almost any cases.
It looks like this:

Rsquared := proc (fnType::string, inFormular, X::{array, list, rtable}, inY::{array, list, rtable}, T::symbol)
  local N, Y, formular, ssRes, ssTotal;
  N := ArrayTools:-NumElems(inY):
  Y := inY:
  formular := inFormular:
  if (fnType = "exp" or fnType = "exponential" or fnType = "power") then
    Y := map(ln, Y):
    formular := ln(formular):
  end if;
  ssRes := add((Y[i]-(eval(formular, T = X[i])))^2, i = 1 .. N):
  ssTotal := N*Statistics:-CentralMoment(Y, 2):
  return evalhf(1-ssRes/ssTotal);
end proc:

And is used this way:
X := <seq(i, i = 1 .. 20)>;
Y := <0.07, 2, .16, .24, .36, .5, .8, 1.2, 1.8, 8, 4, 6, 9, 15, 20, 30, 43, 66.9, 100, 150>;
fitFn := ExponentialFit(X, Y, x);
R^2 = Rsquared("exp", fitFn, X, Y, x);

Since this is my first question in mapleprimes.com I don't know how to mark this tread answered – if I need to do so.

Thanks Erik

Just to make sure that I understand this:

When I want to fit on a exponential function I should perform a log on my Y data, as use did

When it is a power function I should also perform a log on my Y data:

X := <seq(i, i = 1 .. 20)>;
Y := <2.6, 3, 3.6, 4, 4.5, 5, 5.7, 6, 6.7, 7, 7.8, 8, 8.5, 9, 9.6, 10.1, 10.6, 11, 12, 12.4)>;
ssRes := PowerFit(X, Y, x, output = 'residualsumofsquares');
Y := log~(Y);
ssTotal := ArrayTools:-NumElems(Y)*CentralMoment(Y, 2);
R^2 = 1-ssRes/ssTotal; #0.9627722617

But in any other case the Y data shouldn't be modified:

X := <seq(10*i, i = 0 .. 18)>;
Y := <0, .4, .8, 1.9, 4, 7.1, 10.1, 14.6, 15.9, 12.3, 11.5, 9.4, 6.1, 2.6, 1.6, .8, .2, 0, 0>;
f := (x) -> a*sin((1/180)*x*Pi)^n;
ssRes := Fit(f(x), X, Y, x, output = 'residualsumofsquares');
ssTotal := ArrayTools:-NumElems(Y)*CentralMoment(Y, 2);
R^2 = 1-ssRes/ssTotal; #0.9062393748

 

 

Also how dose maple calculate the residual sum of squares. I'm interested in this because I not always want to make a fit
but just want to compare the results to an already know function.

I have tryed with this:  
residualsumofsquares := proc (f, X, Y, T)
   local N;
   N := ArrayTools:-NumElems(Y);
   return add((Y[i]-(eval(f, T = X[i])))^2, i = 1 .. N)
end proc;

But it dosn't work when it is a exponential or power function:

X := <seq(i, i = 1 .. 20)>;
Y := <0.07, 2, .16, .24, .36, .5, .8, 1.2, 1.8, 8, 4, 6, 9, 15, 20, 30, 43, 66.9, 100, 150>;
ssRes := ExponentialFit(X, Y, x, output = 'residualsumofsquares'); #8.05275870047944231
fitFn := ExponentialFit(X, Y, x);
residualsumofsquares(fitFn, X, Y, x); #634.4706207160136 – should be ssRes

The question is:
– are I'm correct when I say the log~(Y) only should be used when it is an exponential or power function?
– how to calculate the residual sum of squares when it is a exponential or power function?

 

 

Thanks Erik

Just to make sure that I understand this:

When I want to fit on a exponential function I should perform a log on my Y data, as use did

When it is a power function I should also perform a log on my Y data:

X := <seq(i, i = 1 .. 20)>;
Y := <2.6, 3, 3.6, 4, 4.5, 5, 5.7, 6, 6.7, 7, 7.8, 8, 8.5, 9, 9.6, 10.1, 10.6, 11, 12, 12.4)>;
ssRes := PowerFit(X, Y, x, output = 'residualsumofsquares');
Y := log~(Y);
ssTotal := ArrayTools:-NumElems(Y)*CentralMoment(Y, 2);
R^2 = 1-ssRes/ssTotal; #0.9627722617

But in any other case the Y data shouldn't be modified:

X := <seq(10*i, i = 0 .. 18)>;
Y := <0, .4, .8, 1.9, 4, 7.1, 10.1, 14.6, 15.9, 12.3, 11.5, 9.4, 6.1, 2.6, 1.6, .8, .2, 0, 0>;
f := (x) -> a*sin((1/180)*x*Pi)^n;
ssRes := Fit(f(x), X, Y, x, output = 'residualsumofsquares');
ssTotal := ArrayTools:-NumElems(Y)*CentralMoment(Y, 2);
R^2 = 1-ssRes/ssTotal; #0.9062393748

 

 

Also how dose maple calculate the residual sum of squares. I'm interested in this because I not always want to make a fit
but just want to compare the results to an already know function.

I have tryed with this:  
residualsumofsquares := proc (f, X, Y, T)
   local N;
   N := ArrayTools:-NumElems(Y);
   return add((Y[i]-(eval(f, T = X[i])))^2, i = 1 .. N)
end proc;

But it dosn't work when it is a exponential or power function:

X := <seq(i, i = 1 .. 20)>;
Y := <0.07, 2, .16, .24, .36, .5, .8, 1.2, 1.8, 8, 4, 6, 9, 15, 20, 30, 43, 66.9, 100, 150>;
ssRes := ExponentialFit(X, Y, x, output = 'residualsumofsquares'); #8.05275870047944231
fitFn := ExponentialFit(X, Y, x);
residualsumofsquares(fitFn, X, Y, x); #634.4706207160136 – should be ssRes

The question is:
– are I'm correct when I say the log~(Y) only should be used when it is an exponential or power function?
– how to calculate the residual sum of squares when it is a exponential or power function?

 

 

Page 1 of 1