2012eScholarship (California Digital Library)Open access

And Now for Something Completely Different: Python in Cognitive Science

Mark W. Andrews, Jesse Dí­az

Open full text 0 citations

Abstract

And Now for Something Completely Different: Python in Cognitive Science Mark Andrews (m.andrews@ntu.ac.uk) Jesse Diaz (jesse.diaz@ntu.ac.uk) Division of Psychology, Nottingham Trent University Nottingham NG1 4B,UK for rapid prototyping and development. Both allow for seam- less extension using external modules written in compiled languages like C/C++ and Fortran. Notable advantages of Python, however, include that it is a general-purpose language whose application goes far beyond numerical array process- ing. Python is one of the top five programming language currently in use throughout the world. Python is a remark- ably well-designed object-oriented language whose standard library is large and comprehensive. Finally, Python is non- commercial open-source software distributed according to an unrestricted software license. Likewise, its large set of third- party extension modules and libraries are, almost without ex- ception, also distributed using unrestricted or public open- source software licenses. Keywords: Python; Programming; Scientific Computing; Nu- merical Computing; Computational Modelling; Experimental Design; Stimuli Presentation Software; Data Analysis; Objectives and Scope The objective of this tutorial is to introduce and motivate the use of the Python programming language in cognitive science research. Within the last 10 years, the development of scien- tific and numerical libraries in Python has grown to the point where Python can now be used as a scientific and numerical computing environment comparable to products like Matlab and Mathematica. As of yet, however, it appears that knowl- edge of the potential applications of Python to research in cognitive science is still rather limited. The aim of this tu- torial, therefore, is to describe these areas of application and to advocate the advantages and appeals of using Python as the principal programming language in cognitive science re- search. Given the generality of the tools being discussed, it is hoped that this tutorial will have widespread appeal and relevance. Numerical and Scientific Python The basic Python language as introduced in the previous sec- tion lacks n-dimensional numerical arrays and the ability to easily plot and visualize data. These capabilities, in addition to a large number of more special-purpose scientific libraries are provided by the Scipy/Numpy suite of modules. These li- braries are seamlessly integrated with ipython to create a rich interactive array-processing and visualization environment, comparable in functionality to Matlab and Mathematica. We will begin this section by describing ipython’s capa- bilities more extensively than done in the previous section. These include: Interactive high-performance parallel comput- ing for clusters and multicore architectures, an online interac- tive Notebook comparable to that used in Mathematica, sql- based searchable command histories, in-line graphics, and symbolic mathematics with TEX-based output. Having established how to use ipython, the audience will be encouraged to follow the examples as we discuss the the following topics: Outline of Tutorial The tutorial will be divided into three main parts. The first part introduces the Python language generally. The second introduces numerical and scientific programming in Python The third part introduces how to develop computer-based psy- chology and psychophysics experiments using Python. The tutorial will involve both classroom style lectures with slides and workshop style computer-based worked examples and exercises. The audience are encouraged to bring their own laptop, and all necessary software will be provided in advance. General Introduction In order to introduce Python, we will begin by describing the fundamentals of the Python language. We will also demon- strate how to start an interactive Python session using the ipython environment. The audience will be encouraged to follow the examples themselves using their own computers. As part of this introduction, we will also compare Python to its alternatives, paying particular attention to comparison with Matlab. This comparison is inevitable, given that Mat- lab has traditionally been the principal scientific computing tool in cognitive science. Notable points of similarity be- tween Python and Matlab are that both offer an interactive array-processing and visualization environment using high- level dynamic programming languages. Both are designed Arrays: General n-dimensional arrays and their operations (e.g. element-wise function application, summing, slicing, indexing, searching) are provided by numpy. 2d visualization: Plotting and visualization, especially of 2d data, are provided by matplotlib, amongst others. 3d visualization: Complex 3d graphics are provided by mayavi. Parallel computing: Interactive high-performance and paral- lel programming is a built-in functionality of python. Integration with C/C++ and Fortran: Interfaces to programs written in compiled languages like C/C++ or Fortran are pro-

Open-access reader

About this research paper

What this paper is about

And Now for Something Completely Different: Python in Cognitive Science Mark Andrews (m.andrews@ntu.ac.uk) Jesse Diaz (jesse.diaz@ntu.ac.uk) Division of Psychology, Nottingham Trent University Nottingham NG1 4B,UK for rapid prototyping and development. Both allow for seam- less extension using external modules written in compiled languages like C/C++ and Fortran. Notable advantages of Python, however, include that it is a general-purpose language whose application goes far beyond numerical array process- ing. Python is one of the top five programming language currently in use throughout the world. Python is a remark- ably well-designed object-oriented language whose standard library is large and comprehensive. Finally, Python is non- commercial open-source software distributed according to an unrestricted software license. Likewise, its large set of third- party extension modules and libraries are, almost without ex- ception, also distributed using unrestricted or public open- source software licenses. Keywords: Python; Programming; Scientific Computing; Nu- merical Computing; Computational Modelling; Experimental Design; Stimuli Presentation Software; Data Analysis; Objectives and Scope The objective of this tutorial is to introduce and motivate the use of the Python programming language in cognitive science research. Within the last 10 years, the development of scien- tific and numerical libraries in Python has grown to the point where Python can now be used as a scientific and numerical computing environment comparable to products like Matlab and Mathematica. As of yet, however, it appears that knowl- edge of the potential applications of Python to research in cognitive science is still rather limited. The aim of this tu- torial, therefore, is to describe these areas of application and to advocate the advantages and appeals of using Python as the principal programming language in cognitive science re- search. Given the generality of the tools being discussed, it is hoped that this tutorial will have widespread appeal and relevance. Numerical and Scientific Python The basic Python language as introduced in the previous sec- tion lacks n-dimensional numerical arrays and the ability to easily plot and visualize data. These capabilities, in addition to a large number of more special-purpose scientific libraries are provided by the Scipy/Numpy suite of modules. These li- braries are seamlessly integrated with ipython to create a rich interactive array-processing and visualization environment, comparable in functionality to Matlab and Mathematica. We will begin this section by describing ipython’s capa- bilities more extensively than done in the previous section. These include: Interactive high-performance parallel comput- ing for clusters and multicore architectures, an online interac- tive Notebook comparable to that used in Mathematica, sql- based searchable command histories, in-line graphics, and symbolic mathematics with TEX-based output. Having established how to use ipython, the audience will be encouraged to follow the examples as we discuss the the following topics: Outline of Tutorial The tutorial will be divided into three main parts. The first part introduces the Python language generally. The second introduces numerical and scientific programming in Python The third part introduces how to develop computer-based psy- chology and psychophysics experiments using Python. The tutorial will involve both classroom style lectures with slides and workshop style computer-based worked examples and exercises. The audience are encouraged to bring their own laptop, and all necessary software will be provided in advance. General Introduction In order to introduce Python, we will begin by describing the fundamentals of the Python language. We will also demon- strate how to start an interactive Python session using the ipython environment. The audience will be encouraged to follow the examples themselves using their own computers. As part of this introduction, we will also compare Python to its alternatives, paying particular attention to comparison with Matlab. This comparison is inevitable, given that Mat- lab has traditionally been the principal scientific computing tool in cognitive science. Notable points of similarity be- tween Python and Matlab are that both offer an interactive array-processing and visualization environment using high- level dynamic programming languages. Both are designed Arrays: General n-dimensional arrays and their operations (e.g. element-wise function application, summing, slicing, indexing, searching) are provided by numpy. 2d visualization: Plotting and visualization, especially of 2d data, are provided by matplotlib, amongst others. 3d visualization: Complex 3d graphics are provided by mayavi. Parallel computing: Interactive high-performance and paral- lel programming is a built-in functionality of python. Integration with C/C++ and Fortran: Interfaces to programs written in compiled languages like C/C++ or Fortran are pro-

Why it matters

A significance statement is not available in the OpenAlex record.

Key contribution

A contribution statement is not available in the OpenAlex record.

Method / approach

Method details are not available in the OpenAlex metadata.

Main findings

Findings are not separately available in the OpenAlex metadata.

Limitations

Limitations are not available in the OpenAlex metadata.

Applications

Application details are not available in the OpenAlex metadata.

Available abstract

And Now for Something Completely Different: Python in Cognitive Science Mark Andrews (m.andrews@ntu.ac.uk) Jesse Diaz (jesse.diaz@ntu.ac.uk) Division of Psychology, Nottingham Trent University Nottingham NG1 4B,UK for rapid prototyping and development. Both allow for seam- less extension using external modules written in compiled languages like C/C++ and Fortran. Notable advantages of Python, however, include that it is a general-purpose language whose application goes far beyond numerical array process- ing. Python is one of the top five programming language currently in use throughout the world. Python is a remark- ably well-designed object-oriented language whose standard library is large and comprehensive. Finally, Python is non- commercial open-source software distributed according to an unrestricted software license. Likewise, its large set of third- party extension modules and libraries are, almost without ex- ception, also distributed using unrestricted or public open- source software licenses. Keywords: Python; Programming; Scientific Computing; Nu- merical Computing; Computational Modelling; Experimental Design; Stimuli Presentation Software; Data Analysis; Objectives and Scope The objective of this tutorial is to introduce and motivate the use of the Python programming language in cognitive science research. Within the last 10 years, the development of scien- tific and numerical libraries in Python has grown to the point where Python can now be used as a scientific and numerical computing environment comparable to products like Matlab and Mathematica. As of yet, however, it appears that knowl- edge of the potential applications of Python to research in cognitive science is still rather limited. The aim of this tu- torial, therefore, is to describe these areas of application and to advocate the advantages and appeals of using Python as the principal programming language in cognitive science re- search. Given the generality of the tools being discussed, it is hoped that this tutorial will have widespread appeal and relevance. Numerical and Scientific Python The basic Python language as introduced in the previous sec- tion lacks n-dimensional numerical arrays and the ability to easily plot and visualize data. These capabilities, in addition to a large number of more special-purpose scientific libraries are provided by the Scipy/Numpy suite of modules. These li- braries are seamlessly integrated with ipython to create a rich interactive array-processing and visualization environment, comparable in functionality to Matlab and Mathematica. We will begin this section by describing ipython’s capa- bilities more extensively than done in the previous section. These include: Interactive high-performance parallel comput- ing for clusters and multicore architectures, an online interac- tive Notebook comparable to that used in Mathematica, sql- based searchable command histories, in-line graphics, and symbolic mathematics with TEX-based output. Having established how to use ipython, the audience will be encouraged to follow the examples as we discuss the the following topics: Outline of Tutorial The tutorial will be divided into three main parts. The first part introduces the Python language generally. The second introduces numerical and scientific programming in Python The third part introduces how to develop computer-based psy- chology and psychophysics experiments using Python. The tutorial will involve both classroom style lectures with slides and workshop style computer-based worked examples and exercises. The audience are encouraged to bring their own laptop, and all necessary software will be provided in advance. General Introduction In order to introduce Python, we will begin by describing the fundamentals of the Python language. We will also demon- strate how to start an interactive Python session using the ipython environment. The audience will be encouraged to follow the examples themselves using their own computers. As part of this introduction, we will also compare Python to its alternatives, paying particular attention to comparison with Matlab. This comparison is inevitable, given that Mat- lab has traditionally been the principal scientific computing tool in cognitive science. Notable points of similarity be- tween Python and Matlab are that both offer an interactive array-processing and visualization environment using high- level dynamic programming languages. Both are designed Arrays: General n-dimensional arrays and their operations (e.g. element-wise function application, summing, slicing, indexing, searching) are provided by numpy. 2d visualization: Plotting and visualization, especially of 2d data, are provided by matplotlib, amongst others. 3d visualization: Complex 3d graphics are provided by mayavi. Parallel computing: Interactive high-performance and paral- lel programming is a built-in functionality of python. Integration with C/C++ and Fortran: Interfaces to programs written in compiled languages like C/C++ or Fortran are pro-

Key concepts: Python (programming language), Computer science, Programming language, MATLAB, Software, Fortran, Plug-in, Software engineering

Related papers

Back to paper searchBrowse research topicsOriginal source
And Now for Something Completely Different: Python in Cognitive Science — Research Paper | ScholarLens