Attribute Value Mistake

56 views
Skip to first unread message

Wang.Z.H

unread,
Aug 22, 2015, 2:30:30 AM8/22/15
to E-Prime
Hello everyone,

I am puzzled by errors of E-prime.

In my experiment, subjects could only response "f/j" and may get score 0 or 1 in each trial.
The score will be accumulate at attribute "Total" through out experiment.

If the subjects' responses are different between two consecutive trials
("game.RESP" at trial Nth is "f/j", and then trial N+1th is "j/f")
,then "Total" will be subtracted 0.2.

Question 1: (See the first attached picture "zero problem") 
Why did trial 11th show the error outcome (minus 16 power of ten, not equal to 0 as it should be) after shifting response 

between 9th and 10th?
And how do I solve it?

Question 2: (See the second and third attached picture "256 problem") 
Why did trial 256th show the error outcome after shifting response between 254th and 255th?
How do I solve it? 
And why did the outputs become normal after 352th?

Thanks very much for any suggestions,

-- Wang.Z.H
256 problem(2).PNG
256 problem.PNG
zero problem.PNG

Wang.Z.H

unread,
Aug 22, 2015, 1:16:37 PM8/22/15
to E-Prime
Sorry, I forgot to put my code on the Internet.

c.SetAttrib "temp",temp

if temp=1 And Game.RESP="f" then
var = c.getAttrib ("varA")
temp = 1
total = total + var
else
end if

if temp=1 And Game.RESP="j" then
var = c.getAttrib ("varB")
temp = 2
total = total + var -0.2
goto LabelshiftB
else
end if

if temp=2 And Game.RESP="j" then
var = c.getAttrib ("varB")
temp = 2
total = total + var
goto LabelstayB
else
end if

if temp=2 And  Game.RESP="f" then
var = c.getAttrib ("varA")
temp = 1
total = total + var -0.2
goto LabelshiftA
   
else
end if


c.SetAttrib "total", total
c.SetAttrib "var", var

David McFarlane

unread,
Aug 24, 2015, 11:15:36 AM8/24/15
to e-p...@googlegroups.com
Just one thought ...

0.2 is a floating-point value. Computer floating-point values are not
exact. To a computer, 10^-16 is practically the same as 0, even though
they are not numerically identical.

If you really want exactness using a floating point value such as 0.2,
then you would have to add some If-Then logic to apply some tolerance to
the results of calculations and adjust results back to exact values as
needed.

But you would do better to abandon any floating point and use only
integers. In this case, you could rescale all of your values by a
factor of 10, and then subtract 2 instead of 0.2. Just make sure that
your integer values do not go out of bounds -- for the programming
language here ( VBA/E-Basic), stay in the range [-32,768, 32,767] for
Integer values, and [-2,147,483,648, 2,147,483,647] for Long values. In
general, for exact computations, you *must* use only integers!

I learned this back in Intro to Computer Programming. If you really
want to understand this better, then you should study how computers
internally represent values using binary.

-- David McFarlane

Cognitology

unread,
Aug 27, 2015, 12:25:55 PM8/27/15
to e-p...@googlegroups.com

Hi Wang,

Today, I’m going through some unanswered emails.

It’s often hard to see what’s wrong with code, because the code is full of redundancies. Perhaps you can explain again slowly:


c.SetAttrib "temp",temp ‘what does this line do, where does temp come from?

 

if temp=1 And Game.RESP="f" then

    var = c.getAttrib ("varA")       ‘NOTE: var isn’t particularly descriptive

    temp = 1            ‘NOTE: this line is tautological

    total = total + var

    ‘no goto here??

else  ‘NOTE: this linecan be deleted

end if

 

if temp=1 And Game.RESP="j" then

    var = c.getAttrib ("varB")

    temp = 2

    total = total + var -0.2

   goto LabelshiftB ‘where is this label? Also: goto statements can create difficult spaghetti

else  ‘NOTE: this line can be deleted

end if

 

if temp=2 And Game.RESP="j" then

    var = c.getAttrib ("varB")

    temp = 2 ‘NOTE: this line is tautological

    total = total + var

    goto LabelstayB

else ‘NOTE: to delete

end if

 

if temp=2 And  Game.RESP="f" then

    var = c.getAttrib ("varA")

    temp = 1

    total = total + var -0.2

    goto LabelshiftA   

else ‘do delete

end if

 

c.SetAttrib "total", total ‘given the above code, these lines are skipped (unless the LabelshiftA is before this?

c.SetAttrib "var", var

 

 

 

 

 

Let’s clear that up a bit more:

 

if temp=1 then

    if Game.RESP="f" then

        var = c.getAttrib ("varA")

        total = total + var

        ‘still no goto statement here!

    else

        var = c.getAttrib ("varB")

        temp = 2

        total = total + var -0.2

        goto LabelshiftB

    end if ‘temp=1

else ‘if temp=2

    if Game.RESP=”f” then ‘I switched this one up, since the order was strange

        var = c.getAttrib ("varA")

        temp = 1

        total = total + var -0.2

        goto LabelshiftA   

    else

        var = c.getAttrib ("varB")

        total = total + var

        goto LabelstayB

    end if ‘temp = 2

end if

 

c.SetAttrib "total", total

c.SetAttrib "var", var

 

 

And more:

 

if temp=1 then

    if Game.RESP="f" then

        total = total + cdouble(c.getAttrib ("varA"))

        ‘still no goto statement here!

    else

        temp = 2

        total = total-0.2+cdouble(c.getAttrib ("varB"))

        goto LabelshiftB

    end if ‘temp=1

else ‘if temp=2

    if Game.RESP=”f” then ‘I switched this one up, since the order was strange

        temp = 1

        total = total-0.2+cdouble(c.getAttrib ("varA"))

        goto LabelshiftA   

    else

        total = total +cdouble(c.getAttrib ("varB"))

        goto LabelstayB

    end if ‘temp = 2

end if

 

 

Anyway, so we continue, in small steps – I’m sure the dedicated coder will be able to remove more than half of the above, for there’s quite a bit of redundancy. However, it’s getting late, and I assume you’ve already fixed whatever was the problem.

Best,

Michiel

--
You received this message because you are subscribed to the Google Groups "E-Prime" group.
To unsubscribe from this group and stop receiving emails from it, send an email to e-prime+u...@googlegroups.com.
To post to this group, send email to e-p...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/e-prime/be65f5c9-6232-4770-8b99-f4c76017e322%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages