There are too many errors of logic andd ysntax in your code for me to even work out what you might be trying to achieve

In particular you must understand the difference between an assignment and an equation in Maple - you seem to be using one or the other more or less at random. See the comments in the following code for your probable error/misunderstandings

restart;

with(RandomTools):

with(LinearAlgebra):

with(Statistics):

with(plots):

UseHardwareFloats:

interface(rtablesize = infinity):

N := 51;

n := 50;

G := Matrix(N, N, Generate(distribution(Normal(0, 1)), makeproc = true), shape = symmetric):

TG := Transpose(G):

H := (G+TG)*(1/2):

Eigenvs := simplify(Eigenvalues(H));

#

# Scale the entries in Eigenvs by the factor

# 1/sqrt(2*N) ans sort into ascending numerical

# order

# PosEigenvs := convert(Eigenvs/sqrt(2*N), list);

#

PosEigenvs:=sort( 1/sqrt(2*n)*convert(Eigenvs, list));

#

# In the OP's original this command did nothing useful

#

# seqPosEigenvs := seq([PosEigenvs[i]], i = 1 .. N);

#

# So many things wrong with the following; in the following

# loop, each index value will cause the previous one to be

# overwritten, so the only output will be the equation, NB

# *not* an assignment,

#

# Spacing=seqPosEigenvs[n]-seqPosEigenvs[n-1]

#

for i to n-1 do

Spacing = seqPosEigenvs[i+1]-seqPosEigenvs[i]

end do;

#

# So once this loop has finished, the variable Spacing has not

# been assigned to anything (although it has been used as one

# side of an equation) - this is not good and effects are going

# to ripple on for ever

#

# In the following two lines note that

#

# NormalisedSpacing := Spacing/avgSpacing; and

# avgSpacing := Spacing/n;

#

# so

#

# NormalisedSpacing := Spacing/(Spacing/n)

#

# which is guaranteed to return 'n' - whatever Spacing has been

# previously assigned to - and it has not been assigned to

# anything!

#

avgSpacing := Spacing/n;

NormalisedSpacing := Spacing/avgSpacing;

#

# Spacing has not been assigned to anything, and since the

# following is an equation not an assignment, pGOE will not

# be assigned to anything either

#

pGOE = (1/2)*Pi*Spacing*exp(-(1/4)*Pi*Spacing^2);

#

# In the following - so many errors

#

# 1) Again the body is an equation, not an assignment, which

# is probably wrong

# 2) diffSpGOE cannot be used as both an indexed and an

# unindexed variable

# 3) diffSpGOE[0] is unassigned so even if subsequent values

# were indexed, no sensible assignments would be made

# 4) pGOE was used in an equation above, but not an assignment

# so pGOE has no numeric value and in any case is not an

# indexed variable so using pGOE[i+1] is just meaningless

# 5) As noted above NormalisedSpacing has been set equal to

# n: note that again this is not an indexable

#

for i from 0 to n-1 do

diffSpGOE = diffSpGOE[i]+pGOE[i+1]-NormalisedSpacing[i+1]

end do; percentagedifference := 100*diffSpGOE/n;