|
Post by LROD240 on Dec 2, 2004 23:07:32 GMT
I am writing with the complier that I downloaded from this site and I was wondering if anyone could help me simplify this equation. I know that I should be able to put into the loop, but I cant figure it out. The formula is v = [(g1 - M) ^ 2 + .....(gN - m) ^2 / (N -1). There are 12 numbers and the line gets real long if I have to type all off it out. Thanks for the help. And here is what my code looks like:
CLS DIM g(12) FOR i = 1 TO 12 READ g(i) m = m + g(i) / 12 NEXT i v = ((g(1) - m) ^ 2 + (g(2) - m) ^ 2 + (g(3) - m) ^ 2 g4) - m) ^ 2 + (g(5) - m) ^ 2 + (g(6) - m) ^2 + (g(7) - m) ^ 2 + (g(8) - m) ^ 2 + (g(9) - m) ^ 2 + (g(10) - M) ^ 2 + (g(11) - M) ^ 2 + (g(12) - m) ^ 2) / (12 -1) sd = v ^ .5 CLS PRINT "Statistical Analysis of Student Grades" PRINT "--------------------------------------" PRINT PRINT PRINT "Mean =================> ", m PRINT "Variance =============> ", v PRINT "Standard Deviation ===> ", sd PRINT PRINT
|
|
buff1
New Member
Posts: 3
|
Post by buff1 on Dec 3, 2004 1:30:32 GMT
v = ((g(1) - m) ^ 2 + (g(2) - m) ^ 2 + (g(3) - m) ^ 2 g4) - m) ^ 2 + (g(5) - m) ^ 2 + (g(6) - m) ^2 + (g(7) - m) ^ 2 + (g(8) - m) ^ 2 + (g(9) - m) ^ 2 + (g(10) - M) ^ 2 + (g(11) - M) ^ 2 + (g(12) - m) ^ 2) / (12 -1)
---------------------- dim vv(12) for k%=1 to 12 vv(k%)=(g(k%)-m)^2 next V=(Vv(1)+vv(2)+vv(3)+vv(4)+vv(5)+vv(6)+vv(7)+vv(8)+vv(9)+vv(10)+vv(11)+vv(12))/11
|
|
|
Post by Ildûrest on Dec 3, 2004 5:01:55 GMT
I can do an even better job than Buff! Just keep adding/;
for k%=1 to 12 V = V + (g(k%)-m)^2 next V=V/11
|
|
|
Post by LROD240 on Dec 3, 2004 18:33:10 GMT
I can do an even better job than Buff! Just keep adding/; for k%=1 to 12 V = V + (g(k%)-m)^2 next V=V/11 Not to sound like an idiot, but what is the K% and does this go inside of the loop? Or do I make a loop all for itself? Thanks
|
|
buff1
New Member
Posts: 3
|
Post by buff1 on Dec 4, 2004 0:15:21 GMT
In a FOR LOOP you are telling the program FOR K%=start TO finish do something here then NEXT k% the next k% increases k% by 1 until finish is reached
So, if you say For k%= 1 to 10 print "Hello" Next k%
it will print hello 10 times. What Ildurest and I were doing is using a FOR LOOP to simplify your problem at least in line length.
I used a separate array (table) called vv which was dimensioned as having 12 items (13 if you count 0) just like you had with the g() array.
making vv(1)=(g(1)-m)^2 and so on making vv(12)=(g(12)-m)^2
then simply add up the vv elements and divide.
Ildurest did simplify it even more adding all the elements in one FOR LOOP then simply dividing at the end. Im not sure I understand your question about a loop for itself ?
|
|
|
Post by RAMANUJ LAHA on Jan 13, 2016 13:27:09 GMT
SIMPLIFY IN QBASIC (A * B) + C - D
|
|
CAN ANY ONE SOLVE THIS
Guest
|
Post by CAN ANY ONE SOLVE THIS on Jan 13, 2016 13:30:08 GMT
SIMPLIFY IN QBASIC (A * B) + C - D
|
|