Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Mathematics
General TopicsResearchOperations ResearchStatisticsMathematical LogicNumerical AnalysisUndergraduate MathAlgebra HelpRecreational Math
Math Software
MapleMathematicaMATLABScilabSASSPSS

Math Forum / Math Software / Maple / July 2009



Tip: Looking for answers? Try searching our database.

Subscript Selector Error

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John - 02 Jul 2009 16:05 GMT
Maple 13 on microsoft xp.

Execution of the procedure findna, listed below, generates the
message: subscript selector error, and the last if statement is not
executed. The results printed on lines 4, 7 and 8 are correct.

I cannot find an explanation of the error in help.

The procedure pbin computes cumulative binomial probabilities, and fib
[i] is the i-th Fibonacci number. The symbols p0 and alpha denote
probabilities, and c is a positive integer.

findna:=proc(alpha,p0,c)local i,n,L; for i from 1 while pbin(c+fib[i
+1],p0,c)>=1-alpha
>   do n:=i+1
>   end do;
>  L:=[c+fib[n],c+fib[n]+fib[n-3],c+fib[n]+fib[n-2],c-1+fib[n]+fib[n-1]];print(L);
>  for i from n-4 by -1 while i>0
>   do if abs(pbin(L[2],p0,c)-(1-alpha))>=abs(pbin(L[3],p0,c)-(1-alpha))
>       then L[1]:=L[2]+1;L[2]:=L[3];L[3]:=L[3]+fib[i-1];print(L)
>       else L[4]:=L[3]-1;L[3]:=L[2];L[2]:=L[2]-fib[i-1];print(L)
>      end if
>   end do:
>  if pbin(L[3],p0,11)>=1-alpha then na:=L[3] else na:=L[2] end if;
> end proc:

John
A N Niel - 02 Jul 2009 16:48 GMT
In article
<0332c69b-7e30-40cc-9ce0-f508a03b4539@l34g2000vbi.googlegroups.com>,

> subscript selector error,

For example, if u is a list of size 20, then you will get that error
when you compute u[21].  Or u[3.5].  Or u[0].
John - 03 Jul 2009 20:48 GMT
> In article
> <0332c69b-7e30-40cc-9ce0-f508a03b4...@l34g2000vbi.googlegroups.com>,
[quoted text clipped - 3 lines]
> For example, if u is a list of size 20, then you will get that error
> when you compute u[21].  Or u[3.5].  Or u[0].

A N Niel,

The program listed below correctly computes the answer to my problem,
but it also reports an error: invalid subscript selector.

with(Statistics):with(combinat,fibonacci):
> pbin:=(n,p,c)->stats[statevalf,dcdf,binomiald[n,p]](c):
> fib:=seq(fibonacci(i),i=1..25):
[quoted text clipped - 7 lines]
>  end do;
> if pbin(L[3],p0,c)>=1-alpha then na:=L[3] else na:=L[2] end if;

                        [622, 766, 855, 998]

                        [622, 711, 766, 854]

                        [712, 766, 800, 854]

                        [712, 745, 766, 799]

                        [746, 766, 779, 799]

                        [746, 758, 766, 778]

                        [759, 766, 771, 778]

                        [767, 771, 774, 778]

                        [767, 769, 771, 773]

                        [770, 771, 772, 773]

                        [770, 770, 771, 771]

Error, invalid subscript selector

                             na := 771
A N Niel - 04 Jul 2009 01:11 GMT
In article
<47e03125-4411-49f5-aa83-44bb35a8ad6d@b9g2000yqm.googlegroups.com>,

> > In article
> > <0332c69b-7e30-40cc-9ce0-f508a03b4...@l34g2000vbi.googlegroups.com>,
[quoted text clipped - 15 lines]
>
> Error, invalid subscript selector

That's the spot where you compute fib[0] which is an invalid subscript
selector

>                               na := 771
Peter - 05 Jul 2009 22:07 GMT
> The program listed below correctly computes the answer to my problem,
>
> > fib:=seq(fibonacci(i),i=1..25):
> > n:=15:p0:=.01:alpha:=.05:c:=11:
> > L:=[c+fib[n],c+fib[n]+fib[n-3],c+fib[n]+fib[n-2],c-1+fib[n]+fib[n-1]]:

At this stage c=11, n=15, fib[15]=610.
Thus c+fib[n] = 621.

> > print(L);
> > [622, 766, 855, 998]

Your output shows 622 ?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2010 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.