research assistant at VSE/LEE · 2. Choose your weapon 1. Install and use PyCharm (reccomented) or...

24

Transcript of research assistant at VSE/LEE · 2. Choose your weapon 1. Install and use PyCharm (reccomented) or...

Page 1: research assistant at VSE/LEE · 2. Choose your weapon 1. Install and use PyCharm (reccomented) or other text editor 3. Install oTree using guide on webpage 4. Play with the demos
Page 2: research assistant at VSE/LEE · 2. Choose your weapon 1. Install and use PyCharm (reccomented) or other text editor 3. Install oTree using guide on webpage 4. Play with the demos

• research assistant at VSE/LEE

• email: [email protected]• consultations by appointment

• course site: janvavra.github.io• presentations, guides for installation, links, code….

• currently under review, will email you when ready (ETA tomorrow evening)

Page 3: research assistant at VSE/LEE · 2. Choose your weapon 1. Install and use PyCharm (reccomented) or other text editor 3. Install oTree using guide on webpage 4. Play with the demos

• Design and program your own simple economicexperiment using oTree experimental platform.• PhD thesis in experimental?

• Post-doc positions

• Research

• Data gathering

Page 4: research assistant at VSE/LEE · 2. Choose your weapon 1. Install and use PyCharm (reccomented) or other text editor 3. Install oTree using guide on webpage 4. Play with the demos

1. 16.02. - Intro

2. 23.02. – Basic Examples, Examples of documentation for the project

3. 02.03. - More advanced examples

4. 09.03. - Extensions (JavaScript, CSS)

Page 5: research assistant at VSE/LEE · 2. Choose your weapon 1. Install and use PyCharm (reccomented) or other text editor 3. Install oTree using guide on webpage 4. Play with the demos

1. Submit a project documentation with team members names (groups of 1-3 people) to March 7th 23:59 (two days before the last seminar). It should be based on provided template and examples (next lecture) given in seminars.

2. Submit a programmed project to March 23rd

23:59 (two weeks after last seminar). Program should be fully working and contain instructions and main part of the experiment (questionnaire is optional)

Page 6: research assistant at VSE/LEE · 2. Choose your weapon 1. Install and use PyCharm (reccomented) or other text editor 3. Install oTree using guide on webpage 4. Play with the demos

www.otree.org

Documentation and code examples:

http://otree.readthedocs.io/en/latest/

Page 7: research assistant at VSE/LEE · 2. Choose your weapon 1. Install and use PyCharm (reccomented) or other text editor 3. Install oTree using guide on webpage 4. Play with the demos

1. Why oTree?

2. Why Python?

3. oTree and web technologies

4. oTree project structure

5. Demonstration

6. Thinking in oTree

7. Tasks for next week

Page 8: research assistant at VSE/LEE · 2. Choose your weapon 1. Install and use PyCharm (reccomented) or other text editor 3. Install oTree using guide on webpage 4. Play with the demos

Yesterdays assignment: for today read the paper (10 pages) http://www.otree.org/oTree.pdf

Page 9: research assistant at VSE/LEE · 2. Choose your weapon 1. Install and use PyCharm (reccomented) or other text editor 3. Install oTree using guide on webpage 4. Play with the demos

• Runs on every operating system and device (PC, tablets, smartphones).• Requirements:

• server: Python

• client: web browser

• Its based on rich set of technologies used in web development• Object Oriented Programming, Model View Controller

architecture

• Programmed using Python, HTML5, CSS3 (Bootstrap) and JavaScript

• Based on Django web framework used by Instagram, Washington Times…

Page 10: research assistant at VSE/LEE · 2. Choose your weapon 1. Install and use PyCharm (reccomented) or other text editor 3. Install oTree using guide on webpage 4. Play with the demos

• Opensource, flexible, you can program almost anything • You can reuse available libraries from both

Python and JavaScript!!• Python: numpy, matplotlib, pandas, sympy, pyomo..

• JavaScript: React.js, Angular.js, Plotly.js….

• Conditional formatting, complicated graphical elements

• Simulation of energy networks, markets clearings during the experiments

• Multiple treatments, complicated matching….

Page 11: research assistant at VSE/LEE · 2. Choose your weapon 1. Install and use PyCharm (reccomented) or other text editor 3. Install oTree using guide on webpage 4. Play with the demos

• No need for paper instructions

• Automated testing of experiments using bots (test.py, advanced topic, not there)

• Insight to current web technologies

• Real-time feedback and results of the experiment

• Great tools for coding – PyCharm, SublimeText..

Page 12: research assistant at VSE/LEE · 2. Choose your weapon 1. Install and use PyCharm (reccomented) or other text editor 3. Install oTree using guide on webpage 4. Play with the demos

• In the Lab• Kiosk mode in browser, runs over LAN network

• Online• Amazon Mechanical Turk, easy hosting on Heroku

• Field/Classroom• Use Wi-Fi router and one laptop as a server

• Users work on own devices or you will distribute yours (only browser is needed)

• oTree has inbuilt production server, helps to set up and install things

Page 13: research assistant at VSE/LEE · 2. Choose your weapon 1. Install and use PyCharm (reccomented) or other text editor 3. Install oTree using guide on webpage 4. Play with the demos

• No support for real-time interaction of players (yet)• No possibility of real-time auction, real-time chat…

• Games must consists of “steps” or “stages”, will see later

• (can be hacked to have it, but don’t, many risks)

• oTree is based on Django• Django is standalone Python web framework

• Real-time experiment can be programed in Django using JavaScript, AJAX, React...

• But Django is not preprogrammed to shuffle groups, execute code at the start of the new round…

Page 14: research assistant at VSE/LEE · 2. Choose your weapon 1. Install and use PyCharm (reccomented) or other text editor 3. Install oTree using guide on webpage 4. Play with the demos

• Easy to learn, widely used

• Main objective is readability of the code and ease of development

• Python 3.X+

• Python tutorial on the oTree page is sufficient• We only need it as a tool!

• http://otree.readthedocs.io/en/latest/python.html

Page 15: research assistant at VSE/LEE · 2. Choose your weapon 1. Install and use PyCharm (reccomented) or other text editor 3. Install oTree using guide on webpage 4. Play with the demos

Can use any database technology (default is SQLite, in production PostgreSQL)

Stores permanent data about the experiment.

Uses SQL language, but oTree/Django provides a bridge in Python.

Displays webpages

Returns user submitted data to server and server saves it to database

Provides logic of the experiment “backend”

Written in Python/Django

Served webpages to the client (sends code that client translated to webpage)

Loads into memory of the server to execute commands

Page 16: research assistant at VSE/LEE · 2. Choose your weapon 1. Install and use PyCharm (reccomented) or other text editor 3. Install oTree using guide on webpage 4. Play with the demos

• oTree code resides in a folder

• folder contains code for your experiments + another things that oTree needs

Page 17: research assistant at VSE/LEE · 2. Choose your weapon 1. Install and use PyCharm (reccomented) or other text editor 3. Install oTree using guide on webpage 4. Play with the demos
Page 18: research assistant at VSE/LEE · 2. Choose your weapon 1. Install and use PyCharm (reccomented) or other text editor 3. Install oTree using guide on webpage 4. Play with the demos
Page 19: research assistant at VSE/LEE · 2. Choose your weapon 1. Install and use PyCharm (reccomented) or other text editor 3. Install oTree using guide on webpage 4. Play with the demos
Page 20: research assistant at VSE/LEE · 2. Choose your weapon 1. Install and use PyCharm (reccomented) or other text editor 3. Install oTree using guide on webpage 4. Play with the demos

••

Each part is in different folder (as an app) in oTree to be reusable

Page 21: research assistant at VSE/LEE · 2. Choose your weapon 1. Install and use PyCharm (reccomented) or other text editor 3. Install oTree using guide on webpage 4. Play with the demos

Rules of the game:

Each player makes a guess from 0 to 100 (whole numbers).

After all players make their guesses, average of their guesses is taken.

This average is multiplied by 5/4. Player with closest guess to 5/4 of average wins.

If there are multiple winning players, winner is determined at random within them.

Price for the winner: 300 CZk

How to play

1. Connect to Wi-Fi mobileLEEpassword: password

2. Connect to 192.168.110.10/room/exp using your browser

Page 22: research assistant at VSE/LEE · 2. Choose your weapon 1. Install and use PyCharm (reccomented) or other text editor 3. Install oTree using guide on webpage 4. Play with the demos

• Keynesian beauty contest• Are prices of stocks based on fundamental value, or

on opinion of others?

• Is there a Nash equilibrium? • How do you derive it?

• Does it help you to know it for winning the game?

• Iterated rationality of other agents

• What about other variants of the game?• 4/3 of the average, or more?

• only the average

• 2/3 of the average, or less?

Page 23: research assistant at VSE/LEE · 2. Choose your weapon 1. Install and use PyCharm (reccomented) or other text editor 3. Install oTree using guide on webpage 4. Play with the demos
Page 24: research assistant at VSE/LEE · 2. Choose your weapon 1. Install and use PyCharm (reccomented) or other text editor 3. Install oTree using guide on webpage 4. Play with the demos

1. Walkthrough the Python tutorial on oTree page

2. Choose your weapon1. Install and use PyCharm (reccomented) or other text

editor

3. Install oTree using guide on webpage

4. Play with the demos on the oTree page

5. Take a look at the three tutorial experiments in the oTree documentation