Harry Garst

174 Reputation

5 Badges

13 years, 285 days

MaplePrimes Activity


These are replies submitted by Harry Garst

@Kitonum 

replacing the first algsubs with subs gives the intended result:

Expr1 := a/(a+b+c);

subs(a+b+c = d, Expr1);

Expr2 := b/(a+b+c);

algsubs(a+b+c = d, Expr2);

Expr3 := c/(a+b+c);

algsubs(a+b+c = d, Expr3);
                                    a    
                       Expr1 := ---------
                                a + b + c
                               a
                               -
                               d
                                    b    
                       Expr2 := ---------
                                a + b + c
                               b
                               -
                               d
                                    c    
                       Expr3 := ---------
                                a + b + c
                               c
                               -
                               d
 

@Kitonum 

 

Thanks al lot!

My only reason for substitutions is to make seemingly complex matrix results so simple that I can understand its structure. Unfortunately, at this moment I am unable to accomplish this in Maple. 

Paradoxically, the 'simplify' command makes things more complicated by expanding all terms out.

the first and the second example are completely the same (except for the indices [1,1] versus [2,1].

I made a new maple file. The second example is a copied version of the first example, but the indices are changed. The output differs.

mapleprimes2.mw

@Preben Alsholm 

Thanks for diving in this issue.

Now it is time for the maple software engineer who wrote the 'forget' function (error message: Error, (in forget) lexically scoped parameter out of context). Strange name for a function. 

best regards,

Harry Garst

error_message.mw

no_error_message.mw 

 

sorry, I hoped it was something obvious I missed from my part.

In the meantime, I switched to the Optimization package, where I did not encounter any problems.

but, I still am curious why that error occurred.

kind regards,

Harry Garst

@Preben Alsholm 

 

Thanks! You are right!

kind regards,

Harrry

Thanks a lot!

I was trying to figure out what the pattern is, but this code is really beautiful.

kind regards,

Harry Garst

@Preben Alsholm 

 

Thanks for your reply. 

Ten years ago I wrote some code to  deals with the weird scientific notation used in the to be imported textfile (D used instead of E). However, now I see that Maple has no problems parsing the data and the following code works.

restart; with(LinearAlgebra); with(FileTools);with(plots);
file1 := "C:/path/ULSlx3.txt";
Lambda := Matrix(5, 1);
for row to RowDimension(Lambda) do
Lambda[row, 1] := Text[ReadNextFloat](file1)
end do;
Lambda;

So I don't need the old code no more.

old code:

Lambdaread:=proc(Lambda::Matrix,B)

local i,j,r,H,v,temp,c,k;
H:=ImportMatrix(B, delimiter="", datatype=string):
v := Vector(0);
ColumnDimension(H); RowDimension(H);
for i to RowDimension(H) do
H[i, 1] := StringTools[SubstituteAll](H[i, 1], "D", "E");
H[i, 1] := StringTools[SubstituteAll](H[i, 1], "+", "");
temp := sscanf(H[i, 1], "%f %f %f %f %f %f");
convert(temp, Vector);
v := Vector([v, temp]) end do;
eval(v); Dimension(v);
r := RowDimension(Lambda); c := ColumnDimension(Lambda); k := 0;
for i to r do for j to c do k := k+1; Lambda[i, j] := v[k] end do end do;
eval(Lambda);
end proc;

@acer 

 

Thanks! now it works as expected.

 

Harry

@acer 

For some statistical software the user can give restrictions for the parameters. Here a mapping of a probability to zero and one (giving 0.5 the benefit of the doubt)

@Markiyan Hirnyk 

 

This is what Axel wrote in 2008:

"For me the function x^a is not defined in (0,0) as a continous limit, so setting it to a value
would be ok and reading it as exp of limit(ln(x)*x,x=0) I do not have problems with 0^0=1 as
convention."

 

What does he mean: it is both undefined and by convention equal to 1?

Should maple give two answers? undefined and 1?

@acer 

 

Indeed this works in Maple, but unfortunately not in Maple T.A.

It gives the following output:

1 3 \n1 3 \n2 5 \n0 5 \n2 4 \n2 2 \n2 3 \n2 3 \n2 3 \n2 3 \n2 2 \n2 4 \n2 4 \n2 3 \n2 2 \n1 2 \n2 2 \n3 3 \n1 4 \n1 2 \n1 5 \n3 2 \n2 4 \n1 3 \n2 4 \n2 3 \n3 3 \n1 3 \n1 5 \n2 3 \n3 2 \n4 3 \n2 2 \n2 3 \n2 5 \n4 4 \n3 2 \n1 2 \n2 3 \n3 2 \n1 2 \n1 4 \n1 5 \n1 4 \n1 2 \n3 3 \n2 4 \n1 3 \n4 3 \n1 3 \n2 2 \n2 4 \n1 3 \n2 4 \n2 4 \n3 3 \n3 3 \n2 3 \n3 3 \n1 5 \n2 4 \n2 3 \n0 1 \n1 3 \n1 4 \n1 5 \n1 1 \n4 1 \n1 3 \n4 4 \n0 3 \n1 3 \n2 3 \n2 4 \n4 4 \n2 4 \n3 4 \n2 4 \n3 2 \n1 4 \n3 2 \n1 2 \n1 2 \n3 3 \n3 3 \n1 3 \n1 4 \n2 5 \n1 2 \n4 3 \n1 4 \n3 3 \n2 3 \n2 5 \n2 4 \n4 4 \n1 3 \n1 2 \n4 3 \n3 4 \n

 

instead of

1 3

1 3

2 5 etc

Thanks anyway,

Harry

@Harry Garst 

 

Thanks a lot! Now it works!

have a nice weekend!

 

Harry

@Harry Garst 

Thanks.  Although my incorrect syntax does what I aimed for outside a proc.

Unfortunately, your suggestion did not work in a proc:

restart;
Generate:=proc()
local MultivariateNormalSample,S,W,K,M,Z,i;
with(LinearAlgebra): with(MTM): with(StringTools):
MultivariateNormalSample := proc (Sigma, V, N) local d; d := LinearAlgebra:-Dimension(V); LinearAlgebra:-LUDecomposition(Matrix(Sigma, datatype = float[8]), 'method' = 'Cholesky') . ArrayTools:-Alias(Statistics:-Sample(Normal(0, 1), d*N), [d, N])+ArrayTools:-Replicate(Vector[column](V, datatype = float[8]), 1, N) end proc: S := MultivariateNormalSample(`<,>`(`<|>`(1, 2), `<|>`(2, 5)), `<,>`(2, 3), 100):
W := int8~(round~(S)): return W;
end proc;Generate();

What is going on?

Does it work on your computer?

Harry

1 2 3 Page 2 of 3