Harry Garst

174 Reputation

5 Badges

13 years, 284 days

MaplePrimes Activity


These are replies submitted by Harry Garst

@Harry Garst 

I decided to use StringTools. Now I have only one problem left: how to insert line feeds after each row of observations?

 

Here is the source code:

 

mode=Inline@
name=generate@
comment=@
editing=useHTML@
solution=@
algorithm=$datastring1=maple("
with(LinearAlgebra):
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):
with(MTM):
W:=int8~(round~(S)):
with(StringTools):
K:=convert(W,string):
K:=Drop(K,17):
K:=Select(IsDigit, K):
M := seq(PadRight(K[i], 2), i = 1 .. Length(K)):
Z:=M[1]:
for i from 2 to Length(K) do: Z := cat(Z, M[i]): end do:
Z;
");
$datastring=[$datastring1];@
uid=c3067c18-5859-4aa8-9cbb-23fbbb8da3f8@
weighting=1@
numbering=alpha@
part.1.name=sro_id_1@
part.1.answer.units=@
part.1.numStyle= @
part.1.editing=useHTML@
part.1.showUnits=false@
part.1.question=(Unset)@
part.1.mode=Numeric@
part.1.grading=exact_value@
part.1.negStyle=both@
part.1.answer.num=2@
question=<p>&nbsp;</p><p>&nbsp;</p><p><1></p><p>&nbsp; $datastring</p><p><a download="dataset.txt" href="data:text/plain;charset=utf-8,$datastring">download</a></p><p>&nbsp;</p><p>&nbsp;</p>@

I would like to use two strategies:

first, offer the students a simple tab delimited data file.

second, to circumvent browser incompabilities I would like to display the data before the questions section starts.

Therefore, I need the rectangular free format 

1 2

3 4.

If the first method fails a student can select the data from the web page and copy an paste the data in a syntax file.

Otherwise, there will be always a student who complains that he cannot download the data.

Harry

 

@Markiyan Hirnyk 

 

The purpose is to be able to to offer a plain text file with data as a download for students who follow a statistical course.

The students have to learn how to use statistical software (SPSS) for analysing their data. 

Because many, many maple commands simply do not work in Maple T.A. I cannot use straightforward commands like ExportMatrix or writedata etc.

Also the whole library URL and HTTP do not seem to work in the Maple T.A. environment.

 

Fortunately, after several month I found I could use the following code:

<a download="data.txt" href="data:text/plain;charset=utf-8,$datastring">click here for download data</a>

here the complete sourcecode:

name=export data.txt@
comment=@
editing=useHTML@
solution=@
algorithm=$datastring="1 2 3 4 5";@
uid=879b593f-0357-4a07-9420-66416ccf50db@
weighting=1@
numbering=alpha@
part.1.name=sro_id_1@
part.1.answer.units=@
part.1.numStyle= @
part.1.editing=useHTML@
part.1.showUnits=false@
part.1.question=(Unset)@
part.1.mode=Numeric@
part.1.grading=exact_value@
part.1.negStyle=both@
part.1.answer.num=2@
question=<p><1></p><p>&nbsp;</p><p>$datastring</p><p><a download="data.txt" href="data:text/plain;charset=utf-8,$datastring">click here for download data</a></p>@

 

The problem I'm facing now is how to format $datastring as a tab delimited data file (with observations for a single observation unit on a single line):

1 2

3 4

 

This is what I have now in the algorithm section:

$R=maple("
with(LinearAlgebra):
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):
with(MTM):
W:=int8~(round~(S)):
with(StringTools):
K:=convert(W,string):
K:=Drop(K,17);
");

 

with gives as output:

 

K := "1,1,2,0,2,2,2,2,2,2,2,2,2,2,2,1,2,3,1,1,1,3,2,1,2,2,3,1,1,2,3,4,2,2,2,4,3,1,2,3,1,1,1,1,1,3,2,1,4,1,2,2,1,2,2,3,3,2,3,1,2,2,0,1,1,1,1,4,1,4,0,1,2,2,4,2,3,2,3,-1,3,1,1,3,3,1,1,2,1,4,1,3,2,2,2,4,1,1,4,3],[1,2,5,1,4,2,3,3,3,3,3,3,5,3,1,-1,3,4,3,0,2,5,5,0,4,3,4,1,4,2,4,7,3,3,5,8,4,0,2,3,0,2,2,3,1,5,3,1,6,2,3,4,1,4,3,5,5,2,4,4,4,3,-2,0,2,2,-1,4,1,8,-2,1,3,5,8,4,5,4,4,-1,3,1,1,5,4,1,2,5,-1,6,2,4,3,4,3,8,2,1,6,5]])"

I tried using StringTools SubstituteAll to get rid off the non digit characters ]], but SubstituteAll gives an error.

Another attempt was adding the following line:

Select(IsDigit, K);

but then I have to find a way to insert blanks and line feeds.

My purpose is to create an object $datastring as a text string including line feeds.

As many universities offer statistical courses using SPSS I believe my question is more than a personal matter.

the following commands do not work in Maple T.A.

printf("%{c }a\n", A);

 The following error message was generated: The character % cannot be used in a formula

writedata(terminal, convert(A, matrix), string);

  java.io.IOException: Maple computation error

 

Many other commands do also not work in  Maple T.A.

 

 

@Markiyan Hirnyk 

 

sorry, indeed I interpreted FAIL as FALSE.

But indeed 'simplify' does the trick, although I do not understand why.

 

restart; assume(x, 'real');
verify(abs(x), sqrt(x^2), {'equal'});
FAIL
verify(abs(x), simplify(sqrt(x^2)), {'equal'});
true
is(abs(x) = sqrt(x^2));
FAIL
is(abs(x) = simplify(sqrt(x^2)));
true

 

Thanks for your clarification.

 

@Kitonum

 

Here it is. The zooming problem is somewhere in the middle. My purpose is to demonstrate the calculation of a correlation by first calculating deviation scores, then rescale to z-scores, zoom in the graph to demonstrate the rescaling of the variables. Finally, to show the calculation of cross-products, preferably in an animated sequences to prevent overlapping areas.

 so_far_so_good.mw

Yes I was aware of this post and I tried to include points in their solutions, but I did not succeed.

Thanks anyway,

Harry Garst

One way to explain it is that I do  not want to take a random sample from the MVN distribution, but I want to choose values from the MVN in such a way that the scores are as close as possible to the MVN distribution.

 
One possible way might be to obtain N values from the univariate distribution by constructing an N-vector with the z-values that are associated with p = 1/(N+1), 2/(N+1), ..., N/(N+1). Such a vector has an exact univariate normal distribution with m = 0 and s = 1.
 
For a k-variate normal distribution we could construct k such vectors, and reorder their values in such a way that the vectors become orthogonal, in order to obtain k vectors of length N that exactly follow the MVN distribution with m = 0 and S = identity.
 
Thanks Axel, I did not tried it yet, but it looks good. Harry
Thanks Axel, I did not tried it yet, but it looks good. Harry
okay, I finally found the bookmark http://personal.kenyon.edu/hartlaub/MellonProject/mellon.html You can download the library: http://personal.denison.edu/~karian/maple_supplement.html Does anybody know how to use this library in Maple 10 or 11? Maybe it only works in previous versions of Maple. Harry Garst
okay, I finally found the bookmark http://personal.kenyon.edu/hartlaub/MellonProject/mellon.html You can download the library: http://personal.denison.edu/~karian/maple_supplement.html Does anybody know how to use this library in Maple 10 or 11? Maybe it only works in previous versions of Maple. Harry Garst
1 2 3 Page 3 of 3