[Tutor] separately updating parameters

2012-05-31 Thread Zsolt Turi
Dear Pythonists,

I'm using Python 2.7. on Win 7.

Problem description:
Currently, I am working on a reinforcement learning paradigm, where I would
like to update Qa values with
alfaG [if decision_input = 1 and feedback_input = 1] or with
alfaL [ if decision_input = 1 and feedback_value = 0].

   (1) So, I have two lists for input (with two values) :

decision_input = [1,1] - this could be 1,2,3,4,5,6
feedback_input = [1,0] - the value is either 1 or zero

(2) The equation is the following

for gain: Qa = Qa+(alfaG*(feedback_input-Qa)) thus, I would like to
use alfaG only if the i-th element of feedback_input is 1
for lose: Qa = Qa+(alfaL*(feedback_input-Qa)) thus, only if the
i-th element of feedback_input is zero

Qa value is initialized to zero.


(3) Incrementing alfaG and alfaL independently after updating the Qa
value

 alfaG = 0.01 - initial value
 alfaL = 0.01 - initial value

(4) The problematic code :(

decision_input = [1,1]
feedback_input = [1,0]
a = []
alfaG = 0.01
alfaL = 0.01
value = 0.04

for i in range(len(decision_input)):
if decision_input[i] == 1 and feedback_input[i] == 1:
while alfaG < value:
Qa = 0
for feedb in feedback_input:
Qa = Qa+(alfaG*(feedb-Qa))
a.append(Qa)
if decision_input[i] == 1 and feedback_input[i] == 0:
while alfaL < value:
for feedb in feedback_input:
Qa = Qa+(alfaL*(feedb-Qa))
a.append(Qa)
alfaL += 0.01
alfaG += 0.01
print a

after this, I've got the following output:
[0.01, 0.099], [0.02, 0.0196], [0.03, 0.0291]


(5) I have no idea, how to get the following output:

[0.01, 0.099],   [0.01, 0.098],   [0.01, 0.097]   -->thus: alfaG =
0.01, alfaL = 0.01, 0.02, 0.03
[0.02, 0.0198], [0.02, 0.0196], [0.02, 0.0194] -->thus: alfaG = 0.02,
alfaL = 0.01, 0.02, 0.03
[0.03, 0.0297], [0.03, 0.0294], [0.03, 0.0291] -->thus: alfaG = 0.03,
alfaL = 0.01, 0.02, 0.03

Since both alfaG and alfaL have 3 values, I have 3x3 lists.

Does anyone have an idea, how to modify the code?

Best regards,
Zsolt
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] How install Pyramid on a Windows 7 computer?

2012-05-31 Thread Tamar Osher

Months ago, I learned Python version 3.  I have read a few books, and want to 
learn how to use Python for the web.  Pyramid is a Python web framework that is 
ready for Python version 3, but I don't know how to install it on my Windows 7 
computer.  Online, there are no Pyramid installation instructions that discuss 
how to install Pyramid on a Windows 7 computer.  Can someone please help me?
from Tamar Osher, emeraldoff...@hotmail.com

 








  ___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How install Pyramid on a Windows 7 computer?

2012-05-31 Thread Vince Spicer
Step 1)  install Ubuntu

OK sorry couldn't resist.

This should help.
http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/install.html#installing-pyramid-on-a-windows-system

Vince

On Thu, May 31, 2012 at 10:20 AM, Tamar Osher wrote:

>  Months ago, I learned Python version 3.  I have read a few books, and
> want to learn how to use Python for the web.  Pyramid is a Python web
> framework that is ready for Python version 3, but I don't know how to
> install it on my Windows 7 computer.  Online, there are no Pyramid
> installation instructions that discuss how to install Pyramid on a Windows
> 7 computer.  Can someone please help me?
>
> from Tamar Osher, emeraldoff...@hotmail.com
>
>
> **
> *
>
>
>
> *
>
> * *
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How install Pyramid on a Windows 7 computer?

2012-05-31 Thread James Reynolds
I don't think django 1.5 is ready, but they are targeting python3k. There
is a fork of django i think on bitbucket that works as well.
On May 31, 2012 12:33 PM, "Vince Spicer"  wrote:

> Step 1)  install Ubuntu
>
> OK sorry couldn't resist.
>
> This should help.
>
> http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/install.html#installing-pyramid-on-a-windows-system
>
> Vince
>
> On Thu, May 31, 2012 at 10:20 AM, Tamar Osher 
> wrote:
>
>>  Months ago, I learned Python version 3.  I have read a few books, and
>> want to learn how to use Python for the web.  Pyramid is a Python web
>> framework that is ready for Python version 3, but I don't know how to
>> install it on my Windows 7 computer.  Online, there are no Pyramid
>> installation instructions that discuss how to install Pyramid on a Windows
>> 7 computer.  Can someone please help me?
>>
>> from Tamar Osher, emeraldoff...@hotmail.com
>>
>>
>> **
>> *
>>
>>
>>
>> *
>>
>> * *
>>
>>
>> ___
>> Tutor maillist  -  Tutor@python.org
>> To unsubscribe or change subscription options:
>> http://mail.python.org/mailman/listinfo/tutor
>>
>>
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] iPython check if user running script is root user (Linux)

2012-05-31 Thread Dave
Hi. What is the right way to have an iPython script check to see if the
user is currently root?

Here's how I do it in bash scripts:


## CHECK USERNAME PRIVILEGE


if [ $(id -u) != "0" ];then
   echo "This script must be run as root."
   exit 1
fi
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] iPython check if user running script is root user (Linux)

2012-05-31 Thread Alan Gauld

On 31/05/12 23:21, Dave wrote:

Hi. What is the right way to have an iPython script check to see if the
user is currently root?


I don;t know anything much about ipython but so far as IO know its just 
a shell on standard python so:


os.getuid()

should work.
In general if you are trying to replace bash with python look at the
os, shutil, glob, os.path modules as a first port of call.

hth

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] iPython check if user running script is root user (Linux)

2012-05-31 Thread Corey Richardson
On Thu, 31 May 2012 18:21:22 -0400
Dave   wrote:

> Hi. What is the right way to have an iPython script check to see if
> the user is currently root?
> 
> Here's how I do it in bash scripts:
> 
> 
> ## CHECK USERNAME PRIVILEGE
> 
> 
> if [ $(id -u) != "0" ];then
>echo "This script must be run as root."
>exit 1
> fi

import os
if os.environ['USER'] != 'root':
print('This script must be run as root.')
exit(1)


-- 
Corey Richardson
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] iPython check if user running script is root user (Linux)

2012-05-31 Thread Emile van Sebille

On 5/31/2012 3:21 PM Dave said...

Hi. What is the right way to have an iPython script check to see if the
user is currently root?


Googling for "python check if user is root" yields the answer:


import os, sys

# if not root...kick out
if not os.geteuid()==0:
sys.exit("\nOnly root can run this script\n")


See 
http://code.activestate.com/recipes/299410-root-access-required-to-run-a-script/


Emile

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] iPython check if user running script is root user (Linux)

2012-05-31 Thread Dave
Thanks. I like the integer-based option.

Since this is my first question to the list, is it appropriate to reply
with a "thanks, that solved it" or is that considered unnecessary?

On Thu, May 31, 2012 at 6:30 PM, Emile van Sebille  wrote:

> On 5/31/2012 3:21 PM Dave said...
>
>  Hi. What is the right way to have an iPython script check to see if the
>> user is currently root?
>>
>
> Googling for "python check if user is root" yields the answer:
>
>
> import os, sys
>
> # if not root...kick out
> if not os.geteuid()==0:
>sys.exit("\nOnly root can run this script\n")
>
>
> See http://code.activestate.com/**recipes/299410-root-access-**
> required-to-run-a-script/
>
> Emile
>
>
> __**_
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/**mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] iPython check if user running script is root user (Linux)

2012-05-31 Thread Alan Gauld

On 01/06/12 00:18, Dave wrote:

Thanks. I like the integer-based option.

Since this is my first question to the list, is it appropriate to reply
with a "thanks, that solved it" or is that considered unnecessary?


Its not necessary but its not frowned on either. It is most useful where 
numerous different options are being suggested since it indicates to 
future googlers which option worked best for the OP...



--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor