Josci95

50 Reputation

One Badge

6 years, 286 days

MaplePrimes Activity


These are questions asked by Josci95

restart;
Digits := 25;

# Setup.
de := diff( x(t), t ) = a * y(t), diff( y(t), t ) = b * x(t);
ic := x(0) = 1, y(0) = 0;
sol := dsolve( { de, ic } ):

# Sample values for specific parameter values.
a0, b0 := 1.0, 0.25:
T := evalf( [ seq( i, i=1..5 ) ] ):
X := [ seq( eval['recurse']( x(t), [ op( sol ), a = a0, b = b0 ] ), t=T ) ]:
Y := [ seq( eval['recurse']( y(t), [ op( sol ), a = a0, b = b0 ] ), t=T ) ]:

# Numerical solution.
sol := dsolve( { de, ic }, 'numeric', 'range'=min(T)..max(T), 'abserr'=1e-15, 'maxfun'=0, 'parameters'=[a,b] ):

# Procedure to return values for specific time and parameter values.
u := proc( t, a, b )
	sol( 'parameters' = [ ':-a' = a, ':-b' = b ] ):
	try
		return eval( [ x( ':-t' ), y( ':-t' ) ], sol( t ) ):  
	catch:
		return 10000:
    end try:
end proc:

# Procedure to return objective function.
r := proc( a, b )
	local A, t, p, q, x, y:
	A := ListTools:-Flatten( [ seq( u( t, a, b ), t=T ) ] -~ zip( (x,y) -> [x,y], X, Y ) ):
	return foldl( (p,q) -> p + q^2, 0, op(A) ):
end proc:

# Find parameter values for bet fit.
Optimization:-Minimize( 'r'(a,b), a=-10..10, b=-10..10 );

I was provided the code above by Maple support, to fit a model to data using the Optimization package. I have tried to adapt this to a situation where one might only have the X variable data and so the model should only fit to that data.  I did this by deleting the , y( ':-t' ) in the try catch statement and then having the zip statement read as zip( (x) -> [x], X).

When I try to run that code, I get the error:

Error, (in Optimization:-NLPSolve) invalid input: zip uses a 3rd argument, b, which is missing

Anybody have an idea how to solve this?

 

Jo

I am creating a randomised dataset in a workbook, I want the students to use this data but I also want to save the matrix within the same workbook as a csv file so that when I come to look at their work I will see the exact dataset they were supplied with. Can anyone advise on how I might do this:

The code is:

x := convert([seq(1..100)], Vector[column]):

y := 0.1*~x:

with(SignalProcessing):

tmp := GenerateGaussian(100, 2, .6):

tmp2 := convert(tmp*~y, Vector[column]):

ad1 := <<x>|<tmp2>>:

I tried - Export("this:///DataFiles/exdat.csv",ad1):

but get the Error message - Error, (in FileTools:-OpenURI) entry with path '/DataFiles/exdat.csv' is not found

Is what I'm trying to achieve even possible?

Thanks in advance

Jo (p.s. pretty new to Maple)

 

Can anyone advise me on the difference between the Internally and Externally Standardized Residuals from the LinearFit procedure? 

 

Sincerely

 

Jo

Dear all,

I am new to Maple and trying to figure out the use of dataframes. The help files say you can use dataframes in plotting but I keep getting errors. I have the following code which uploads a short dataframe with column headers which include x and y. I use

with(plots);
with(Statistics);
mydat := Import("this:///Datafiles/greg.csv"); 

with(mydat);
dataplot(x,y);

I receive the following error message 
Error, (in Plot:-DataPlot) invalid input: lhs received _m4754289856, which is not valid for its 1st argument, expr

Can anyone spot what I'm doing wrong?

Thanks in advance

Jo

 

I have the following Maple code.

 

x := [5, 10, 15, 20];

y := [4.22, 7.49, 12.24, 19.60];  

yui := [2.48, 3.76, 6.11, 14.60];

yli := [2.27, 3.34, 6.09, 10.90];

 

with(Statistics): with(plots):

p1 := ErrorPlot(y, coords = x, yerrors = yui);

this produces a plot with error bars. The problem is that I acutally have unequal errors. In the ErrorPlot helpfile it says:

"This options specifies errors along the x-axis. The array of errors must have the same number of elements. To specify right errors and left errors separately, use the list of two vectors." (this pertains to xerrors obviously but below it says the same applies to yerrors)

I have tried entering the code above with yerrors=[yli,yui] and with yerrors={yli,yui}....but neither option works and I get the error:

"Error, invalid input: Statistics:-ErrorPlot expects value for keyword parameter yerrors to be of type {identical(default), [{array, list, rtable, DataFrame, DataSeries}, {array, list, rtable, DataFrame, DataSeries}], {array, list, rtable, DataFrame, DataSeries}}, but received {[2.27, 3.34, 6.09, 10.90], [2.48, 3.76, 6.11, 14.60]}"

Can anyone advise me on what I'm doing wrong - I am very new to Maple.

Jo

 

Page 1 of 1