plummie

140 Reputation

3 Badges

14 years, 305 days

MaplePrimes Activity


These are answers submitted by plummie

I'm trying to find the minimum distance between two e'values of an nxn matrix. ie. for each e'value E[1]....E[n] i need to work out which other e'value it is closest to and then put the distance in a list.

like so:
N:= [abs(E[1]-E[5]),abs(E[2]-E[21]),abs(E[3]-E[7]),.....etc

This final list N is made up of values from 500+ nxn matrices so that i able to evaluate them statistically. I'm just using the op(N) call to put them all together

So really I am looking for a mindiff but for each e'value.

Just a simple example for you. Pretend you want to know if a calculation named a is bigger than 6, you could write.

if a>6 then;
print( a bigger than 6);
else
print( a less than 6);
fi;

I have managed to make the loop work, except that for my first entry of the first loop where E[i]=E[2] I do not get given the correct answer. Can anyone see why it doesn't work as I have no idea? (running this again it gave me all correct entries, unsure why it failed first time as did not edit the code)


for i from 2 to n do

a := abs(E[i]-E[1]);

for j from 2 to n do

if i <> j then

b := abs(E[i]-E[j])

end if;

if b < a

then a := b

end if end do;

N := [op(N), a] end do;

for i to 1 do a := abs(E[i]-E[2]);

for j from 3 to n do

if i <> j then b := abs(E[i]-E[j])

end if;

if b < a

then a := b

end if end do;

N := [op(N), a]

end do;

 

Also when I add the loop into my calculation, which is inside a loop 'to 500 do' I receive the message 'Error cannot determine if this expression is true or false b<2.9343729273....'

which I don't understand as it will work when I remove the loop around it. Clearly doing the calculations individually 500 times is ridiculously time consuming and unnecessary. Can you help?

Thank-you but I looked at that and I need to put the values into a matrix so it didn't work.
I have decided to use with(RandomTools)

Generate(distribution(Normal(0,1)) it seems to work
I also have Generate(distribution(Normal(0,.5))+I*Generate(distribution(Normal(0,.5))

Hi, sorry I did mean a list not an array. (It was easier to do it that way)

I managed to figure it out, in case anyone else is interested I used
N:=[op(N),a] to add a onto my list of elements.

Thankyou for your help though.

Hi, thanks for your reply but I don't want to subtract the eigenvectors, I want to subtract the eigenvalues from each other. I can't work out how to access them as elements though so that I can subtract them

Hi, this has confused me somewhat. How do I put it in a hermitian matrix wrapper?

I am not an experienced maple user and so find this very confusing,

inputting Arraytools[Reshape][shape = hermitian](statistics[sample](normal(0,1),4)2,2,)

produces a normally dist matrix but it is not hermitian, how can I do this?

Thanks for your replies.

I have previously been using the randommatrix(2,2,outputoptions = [shape = hermitian]) command but wasn't sure how to make sure the entries were in the standard normal.

Then I assume that from your comments if I use RandomMatrix(2,2,generator=0..1.0,outputoptions=[shape=hermitian]) command this will give me my hermitian matrix with entries N(0,1) distribution.

I'm guessing that this would be the simplest way to do it and still ensure my matrices are hermitian?

Page 1 of 1