Python Sample Programs
Programs at these websites can be freely downloaded
and used.
The constructer of these websites disclaims all
responsibility.
The user takes responsibility for his/her usage.
Yasuharu Okamoto
An easy way to install Python 3 on CentOS 7.
On PyStan 2.18 /Windows Errors (2018.10.28)
PyStan, the Python interface to Stan, can be installed easily.
I am using PyStan in Windows, Ubuntu, and CentOS 8.
Reliability Coefficient of a
Scale of Categorical Items
Reliability coefficient omega is estimated for a scale of categorical items, and relation of
a scale value and a true score is investigated by calculating correlation coefficient and coefficient of determination.
Reliability Coefficient
of a Scale of Categorical Items (for PyStan 3)
Scripts for Bayesian analysis of categorical items scale were developed in PyStan 3.
Statistical Reliability and
Psychological Reliability
Statistical reliability overestimates psychological reliability.
To evaluate the real relation of observed values and true values
of the concept, we need the psychological reliability.
Reliability in Item Response
Theory
Three aspects of reliability, precision, stability/consistency, predictive power, in Item Response Theory (IRT)
are estimated by simulation. Predictive power indicates the strength of relation between
true values and estimates, so is substantive index in psychological research.
Polychoric/Tetrachoric
Correlation Coefficients
Correlation coefficients of latent variables for categorical variables are called polychoric or
tetrachoric correlation coefficients. These correlations are easily estimated by Bayesian approach
with a grid method.
Up-and-Down Methods with
Multi-Category Rating
Three Category rating (‘Stronger’, ‘Do not know’, ‘Weaker’) or Four Category rating (‘Stronger’, ‘Probably Stronger’, ‘Probably Weaker’, ‘Weaker’)
is adopted for up-and-down methods to estimate Point of Subjective Equality (PSE) and Just Noticeable Difference (JND) by Bayesian Analysis.
Bayesian method is also used to analyze data of the traditional two category rating method.
Estimation by Bayesian method can be expected to bring more accurate estimates than those by traditional averaging.
2AFC Tasks of Signal Detection
Theory
In addition to the standard 2AFC task of signal detection theory (SDT), 2AFC tasks with rating judgment were proposed.
Python scripts using Stan (PyStan) scripts for Bayesian analyses for those methods were also presented.
You can use Python simply with a common text editor.
Moving Figures: Tkinter,
Frame, Canvas
Simple scripts of moving circles, displayed on a canvas
A simple digital clock was made on a canvas in a frame of Tkinter.
C/C++program using Python
script
A simple C/C++ program with a Python script, by which C/C++ program uses Python’s facilities.
When using Pool for multiprocessing, location of input function is critical.
By multiprocessing, we can use CPU power of a contemporary PC efficiently.
The class Pool of Python makes it easy to employ multiprocessing.
A simple example of script, which uses the class Pool for parallel multiprocessing, is prepared.
Non-Identifiable Parameters and
Bayesian Analysis
Bayesian analysis can be applied to a model with non-identifiable parameters.
An example is presented using a multinomial (especially, binary) categorical distribution.
Item Response Theory of Stage
Theory in PyMC3
Stage theory is one of popular theories in psychology.
A simple sample script in PyMC3 is developed for stage theory
Item Response Theory of Stage
Theory in Stan
Stage theory is one of popular psychological theories.
A simple sample script in Stan is developed for stage theory.
Latent Class Item Response
Theory
Standard Item Response Theory assumes that the variable for the trait of a person is continuous.
However, in psychology, trait may be considered to be divided into classes, that is,
a person may be considered to belong to a class. This website presents a sample program
for analyzing data, which is supposed to measure the latent class.
Scattergrams of Dirichlet
Distributions
A simple program takes samples from Dirichlet distributions using numpy module, and
displays scattergrams using seaborn and matplotlib modules.