Melvin Brown

124 Reputation

7 Badges

19 years, 167 days

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are questions asked by Melvin Brown

with(Statistics):

LetList := [C, E, F, H, K, P, T, W, X, Y]; LetList[Sample()];
           LetList := [C, E, F, H, K, P, T, W, X, Y]
Error, invalid input: no implementation of Sample matches the arguments in call, 'Sample:-ModuleApply()'

Can any one help me with random sampling from LetList ?

 

Melvin


 

I wish to add tick marks to a 3D plot of a matrix.

B:=Matrix(10, 10, [[0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 1, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0, 0, 0]]):

Below, I draft a plot of this adjacency matrix B . I have adjusted  the position of the domain graph ticks for the x and y axes to be letters at the midpoints of the matrix elements:

tickList := [1.5 = "W", 2.5 = "P", 3.5 = "K", 4.5 = "C", 5.5 = "Y", 6.5 = "F", 7.5 = "X", 8.5 = "H", 9.5 = "T", 10.5 = "E"];

tickmarks = [tickList, tickList, tickList];

matrixplot(B, axes = [0 .. 12, 0 .. 12, 0 .. 12], heights = histogram, axes = boxed, title = "Above adjacency matrix B - axis order 1-10 \n Basis set: {W,P,K,C,Y,F,X,H,T,E}", labels = ["from", "to", ""], orientation = [0, 0, 0], tickmarks = [tickList, tickList, tickList]);

BUT I would like the z-axis not to be the above letters but instead the real (or integer) values of the matrix elements.  How should I do this, while retaining the x and y axes labels as letters located at the ticklist above.

Please can someone help?

Melvin

Am trying to analyse a set of strings.   Can anyone help?

We have 10 x10 matrix into which we need to add connection score.
ExY := [WPKCPYWFYWCXHY, WPKCTEYFHCFEEE, HYCYTFHYYWWKCE, HYHHTFHKFEYHEH, HKXWYHFECTFFTF, HKWEHPPECWWHTC, HKXWYTPXHFHWYP, HKFEXCTFECXFKP, HKFEYPPEEEPHYW, HYTHCCFEWPPEXX, HKXKXCKFCHTEWK, HYEKPPCKFTWXXW];
Here is the code to create the connection matrix 
A__c = A__a+A__d;
.
Blist:=[W,P,K,C,Y,F,X,H,T,E]:# basis letters
nWords:=numelems(ExY):Wletters:=length(ExY[1]):Bletters:=numelems(Blist):A:=Matrix(Bletters,Bletters):# set up dimensions
for iW from 1 to nWords do  # loop through words
  for iL from 1 to Wletters-1 do # loop through letters of each word
     fromLett:=C(iW,iL); # see char extraction from ExY list above 
     toLett:=C(iW,iL+1); # ditto
     BfromLett:=Search(fromLett,Blist);# column id   <<<<<< the search is returning 0, it works if one uses "A" rather than say fromLett=A 
     BtoLett:=Search(toLett,Blist);# row id   <<<<<  ditto here
     A(BfromLett,BtoLett):=A(BfromLett,BtoLett)+ 1; # add statistic to the A-matrix
  end do; # end letter loop
end do; # end word loop
Error, index out of bounds
The search function is failing: 
Blist; Wletters; Bletters; nWords; fromLett; toLett; BfromLett; BtoLett; A; iW; iL;
                 [W, P, K, C, Y, F, X, H, T, E]
                               14
                               10
                               12
                              "W"
                              "P"
                               0
                               0

                 [0  0  0  0  0  0  0  0  0  0]
                 [                            ]
                 [0  0  0  0  0  0  0  0  0  0]
                 [                            ]
                 [0  0  0  0  0  0  0  0  0  0]
                 [                            ]
                 [0  0  0  0  0  0  0  0  0  0]
                 [                            ]
                 [0  0  0  0  0  0  0  0  0  0]
                 [                            ]
                 [0  0  0  0  0  0  0  0  0  0]
                 [                            ]
                 [0  0  0  0  0  0  0  0  0  0]
                 [                            ]
                 [0  0  0  0  0  0  0  0  0  0]
                 [                            ]
                 [0  0  0  0  0  0  0  0  0  0]
                 [                            ]
                 [0  0  0  0  0  0  0  0  0  0]
 

I wish to process a string of letters into a list of one or more characters which are comma separated at each change of character. The following function will achieve this, but its output is not as list [ ] in the format required.  

Below is a routine to split a character string based on change of character: (ref: https://rosettacode.org/wiki/Split_a_character_string_based_on_change_of_character#Maple)

splitChange := proc (str::string) local start, i, len; start := 1; len := StringTools:-Length(str); for i from 2 to len do if str[i] <> str[start] then printf("%s, ", str[start .. i-1]); start := i end if end do; printf("%s", str[start .. len]) end proc;
splitChange("WPKCPYWYYYXHYY");# 

Here is the output:
W, P, K, C, P, Y, W, YYY, X, H, YY

This print-to screen output is not usable, instead I need the output in list format i.e. ListY:= ["W", "P", "K", "C", "P", "Y", "W", "YYY", "X", "H", "YY"].

Background

 In my model, each of these character strings is a node of a graph, and their adjacencies represent an edges of a graph.  I aim to automatically map strings into a set of directed adjacencies as output; for example:  

AdjSet:= {[W, P], [P, K], [K, C], [C, P], [P, Y], [Y, W], [W,YYY],[YYY, X], [X, H], [H,YY]}.

This set will be the input to a directed graph, e.g: 
M := Digraph(AdjSet); DrawGraph(M);
from which our objective, the adjacency matrix of the nodes can be obtained in MAPLE.  

Help

Can someone please help me by modifying the SplitChange rountine so that it produces output in the form of ListY above? 

Thanks in anticipation of your help

Melvin Brown
 

I am looking for a numerical solver for a parabolic PDE (up to 2nd order derivatives but no mixed ones) on the spatio-temporal domain [X x Y x T], either as an external package or as MAPLE code.  

I have coded the method of lines on the domain [X x T] and indeed also used pdsolve as a check for that case. However, pdsolve (numerical) cannot solve the PDEs on the domain [X x Y x T].  The run times and memory requirements for the latter case would of course be significantly greater.  

I am about to code up the method of lines (in MAPLE) on the domain [X x Y x T], but am wondering whether there exist external FORTRAN or C code packages that would be faster if called up in MAPLE and whose results would then be post-pocessed in MAPLE.

Does anyone have any suggestions?

MRB

3 4 5 6 7 8 Page 5 of 8