Memorandums

知覚・認知心理学の研究と教育をめぐる凡庸な日々の覚書

Octave とMATLAB の違い

2012-10-31 | MATLAB

Mac 上のMATLABで作った実験プログラムを,Windows上で動かす。

1) MATLABをやはり使うなら,なぜかキー入力が誤作動(?)するので,これらをOFFにする。

cf. 2 キーボード入力 - Psychtoolboxをがんばる:心理学、実験、プログラミング

あとは,KbDemoでキーコードを確認,変更する。

2) Octaveで同様に試みたが,画面が出ない。そこで,

octave matlab 違い screen - Google 検索

Octaveでは, Screenとscreenが異なる(小文字は区別される)

ほかいくつか。

 

コメント
  • X
  • Facebookでシェアする
  • はてなブックマークに追加する
  • LINEでシェアする

Rand()

2011-11-14 | MATLAB

>> help Rand
 RAND Uniformly distributed pseudorandom numbers.
    R = RAND(N) returns an N-by-N matrix containing pseudorandom values drawn
    from the standard uniform distribution on the open interval(0,1).  RAND(M,N)
    or RAND([M,N]) returns an M-by-N matrix.  RAND(M,N,P,...) or
    RAND([M,N,P,...]) returns an M-by-N-by-P-by-... array.  RAND returns a
    scalar.  RAND(SIZE(A)) returns an array the same size as A.
 
    Note: The size inputs M, N, P, ... should be nonnegative integers.
    Negative integers are treated as 0.
 
    R = RAND(..., 'double') or R = RAND(..., 'single') returns an array of
    uniform values of the specified class.
 
    Compatibility Note: In versions of MATLAB prior to 7.7, you controlled
    the internal state of the random number stream used by RAND by calling
    RAND directly with the 'seed', 'state', or 'twister' keywords.  That
    syntax is still supported for backwards compatibility, but is deprecated.
    Beginning in MATLAB 7.7, use the default stream as described in
    RANDSTREAM. *これは知らなかった。
 
    The sequence of numbers produced by RAND is determined by the internal
    state of the uniform pseudorandom number generator that underlies RAND,
    RANDI, and RANDN.  Control that default random number stream using its
    properties and methods.  See RANDSTREAM for details about the default
    stream.
 
    Resetting the default stream to the same fixed state allows computations
    to be repeated.  Setting the stream to different states leads to unique
    computations, however, it does not improve any statistical properties.
    Since MATLAB uses the same state each time it starts up, RAND, RANDN, and
    RANDI will generate the same sequence of numbers in each session unless
    the state is changed.
 
    Examples:
 
       Generate values from the uniform distribution on the interval [a, b].
          r = a + (b-a).*rand(100,1);
 
       Generate integer values from the uniform distribution on the set 1:n.
          r = randi(100,1);
 
       Save the current state of the default stream, generate 5 values,
       restore the state, and repeat the sequence.
          defaultStream = RandStream.getDefaultStream;
          savedState = defaultStream.State;
          u1 = rand(1,5)
          defaultStream.State = savedState;
          u2 = rand(1,5) % contains exactly the same values as u1
 
       Replace the default stream with a stream whose seed is based on CLOCK, so
       RAND will return different values in different MATLAB sessions.  NOTE: It
       is usually not desirable to do this more than once per MATLAB session.
          RandStream.setDefaultStream(RandStream('mt19937ar','seed',sum(100*clock)));
          rand(1,5)
 *これを使う。
    See also Randi, randn, RandStream, RandStream/rand, RandStream/getDefaultStream,
             sprand, sprandn, randperm.
    Overloaded methods:
       RandStream/rand
    Reference page in Help browser
       doc rand
>>

 

コメント
  • X
  • Facebookでシェアする
  • はてなブックマークに追加する
  • LINEでシェアする

画像の一部を提示するために

2011-10-31 | MATLAB

画像の一部を切り取る。

1)  .tif 形式のファイルを用いる。

2)  imread() のパラメータで、

'PixelRegion', {ROWS, COLS} を指定する。

 

cf.

http://www.mathworks.co.jp/help/techdoc/ref/imread.html

 

コメント
  • X
  • Facebookでシェアする
  • はてなブックマークに追加する
  • LINEでシェアする

オブジェクトを透明にする

2011-09-06 | MATLAB

実験刺激の作成中。

cf. 透明度の操作

オブジェクトを透明にする

 

コメント
  • X
  • Facebookでシェアする
  • はてなブックマークに追加する
  • LINEでシェアする

Palamedes: PAL_PFML_GoodnessOfFit

2011-08-28 | MATLAB

精神測定関数の適合度

 

>> help PAL_PFML_GoodnessOfFit

 PAL_PFML_GoodnessOfFit     Determine Goodness-of-Fit of psychometric

    function (PF) using method in Wichmann & Hill, 2001, Perception &

    Psychophysics, 63, 1293-1313.

 

Output: 

    'Dev': Deviance (transformed likelihood ratio comparing fit of

        psychometric function to fit of saturated model)   ----> Wichmann & Hill, 2001, p.1303 参照

 

    'pDev': proportion of the B Deviance values from simulations that were

        greater than Deviance value of data. The greater the value of pDev,

        the better the fit.

 

 

 

コメント
  • X
  • Facebookでシェアする
  • はてなブックマークに追加する
  • LINEでシェアする

Palamedes: PFML_Fit: initial value

2011-08-27 | MATLAB

初期値をきめるために。

 

 

>> help PAL_PFML_Fit

 PAL_PFML_Fit   Fit a psychometric function to data using a Maximum 

     Likelihood criterion.

 

'searchGrid': Either a 1x4 vector containing initial guesses for free 

        parametervalues and fixed values for fixed parameters [threshold 

        slope guess-rate lapse-rate] or a structure with vector fields 

        .alpha, .beta, .gamma, .lambda collectively defining a 4D parameter 

        grid through which to perform a brute-force search for initial 

        guesses (using PAL_PFML_BruteForceFit). Fields for fixed parameters 

        should be scalars equal to the fixed value. Note that choices made 

        here have a large effect on processing time and memory usage.

 

    'paramsFree': 1x4 vector coding which of the four parameters in 

        paramsValue are free parameters and which are fixed parameters 

        (1: free, 0: fixed).

 

 

Full example:

 

    options = optimset('fminsearch');

    PF = @PAL_Logistic;

    StimLevels = [-3:1:3];

    NumPos = [55 55 66 75 91 94 97];    %observer data

    OutOfNum = 100.*ones(size(StimLevels));

    searchGrid.alpha = [-1:.01:1];    %structure defining grid to <--- この部分以下で範囲を設定

    searchGrid.beta = 10.^[-1:.01:2]; %search for initial values 

    searchGrid.gamma = .5;

    searchGrid.lambda = [0:.005:.06]; 

 

    %or (not advised):

    % searchGrid = [0 1 .5 0.01];       %Guesses

 

    paramsFree = [1 1 0 1]

 

 

コメント
  • X
  • Facebookでシェアする
  • はてなブックマークに追加する
  • LINEでシェアする

Palamedes

2011-08-26 | MATLAB

PalamedesのDemoから、PAL_PFML_Demoを試す。

PAL_PFML_Demo  Demonstrates use of Palamedes functions to (1) fit a Psychometric Function to some data using a Maximum Likelihood criterion, (2) determine standard errors of free parameters using a bootstrap procedure and (3) determine the goodness-of-fit of the fit.

 

Parametric Bootstrap を指定。以下結果。

Fitting function.....

done:

Threshold estimate: 0.0584

Slope estimate: 66.4521

 

Determining standard errors.....

done:

Standard error of Threshold: 0.0036

Standard error of Slope: 11.1454

 

Determining Goodness-of-fit.....

done:

Deviance: 7.9773

p-value: 0.0900

Elapsed time is 21.034485 seconds.

元データは以下のように指定。

 

%Stimulus intensities

StimLevels = [0.01 0.03 0.05 0.07 0.09 0.11]; 

 

%Number of positive responses (e.g., 'yes' or 'correct' at each of the 

%   entries of 'StimLevels'  

NumPos = [45 55 72 85 91 100];                 

 

%Number of trials at each entry of 'StimLevels'

OutOfNum = [100 100 100 100 100 100];         

 

 

コメント
  • X
  • Facebookでシェアする
  • はてなブックマークに追加する
  • LINEでシェアする

Matlab routines for analyzing psychophysical data

2011-08-25 | MATLAB

精神物理学的データから、精神測定関数を導くためのPsignifit 以外の方法。

Palamedes

Prins, N & Kingdom, F. A. A. (2009) Palamedes:  Matlab routines for analyzing psychophysical data.  http://www.palamedestoolbox.org 

その他 Rなど。

options besides Palamedes

Psyphy

 

コメント
  • X
  • Facebookでシェアする
  • はてなブックマークに追加する
  • LINEでシェアする

Octave

2010-11-01 | MATLAB
Matlab互換というが,どこまで互換かは未確認。
Octave
コメント
  • X
  • Facebookでシェアする
  • はてなブックマークに追加する
  • LINEでシェアする

奇数と偶数の判別

2008-11-30 | MATLAB
Matlabで奇数と偶数の判別をおこなうには、mode かremが利用できる。

cf.
初心者によるMATLABメモ
[基本] 奇数と偶数の判別
http://sach1o.blog80.fc2.com/blog-entry-29.html

mod (MATLAB Function Reference)
http://dl.cybernet.co.jp/matlab/support/manual/r13/toolbox/matlab/ref/?/matlab/support/manual/r13/toolbox/matlab/ref/mod.shtml
rem (MATLAB Function Reference)
http://dl.cybernet.co.jp/matlab/support/manual/r13/toolbox/matlab/ref/?/matlab/support/manual/r13/toolbox/matlab/ref/rem.shtml
コメント
  • X
  • Facebookでシェアする
  • はてなブックマークに追加する
  • LINEでシェアする

心理学実験 Matlab 虎の巻

2008-11-15 | MATLAB
心理学実験 Matlab 虎の巻
Matlabの導入、画像・音声の提示、反応の提示などの例が以下にある。
専門的な精神物理学で利用する視覚刺激、聴覚刺激の作成なども別にあげられている。
http://www.h6.dion.ne.jp/~fff/old/technique/matlab_intro/

http://www.h6.dion.ne.jp/~fff/old/technique/technique.html
コメント
  • X
  • Facebookでシェアする
  • はてなブックマークに追加する
  • LINEでシェアする

bootstrap, psignifitの出力

2008-05-03 | MATLAB
Matlab上のbootstrap, psignifitの出力について

>> helpwin psignifit

:
All other psignifit engine options are supported (see PSYCH_OPTIONS for
details. Of particular interest are the following):

CUTS: the levels at which thresholds and slopes are calculated
default is [0.2 0.5 0.8], which would, in the 2AFC paradigm
which is the default, correspond roughly to 60%, 75% and 90%
correct.

CONF: the cumulative probability values at which confidence interval
boundaries are calculated. The default setting is
[0.023 0.159 0.841 0.977]. If all distributions were Gaussian,
then this would correspond to [-2, -1, +1, +2] standard
deviations from the mean. If the CONF vector has 2 or 4 elements,
then error bars can be plotted from the results using the
function PSYCHERRBAR.

::

コメント
  • X
  • Facebookでシェアする
  • はてなブックマークに追加する
  • LINEでシェアする

psignifit: bootstrap by matlab toolbox

2007-05-05 | MATLAB
信頼区間について
  BCa とは?

>>help PSYCH_GLOSS

:
BCa
the bias-corrected accelerated method of obtaining bootstrap
confidence intervals. For most problems, the coverage of BCa
intervals can be shown to exhibit better convergence than that of
unadjusted bootstrap percentile intervals. See Davison, AC & Hinkley,
DV (1997): Bootstrap methods and their application; Cambridge: CUP,
and Efron, B & Tibshirani, RJ (1993): An Introduction to the Bootstrap;
New York: Chapman & Hall.

References
psignifit -> matlab toolbox
http://bootstrap-software.org/psignifit/toolbox.php#top
コメント
  • X
  • Facebookでシェアする
  • はてなブックマークに追加する
  • LINEでシェアする

bootstrap by Matlab Toolbox

2006-11-26 | MATLAB
Matlab上でbootstrap法。
DataR に刺激強度、正答率、反応数を行列で保持。

>>pfit(DataR, 'shape', ' weibull')

cf.
http://bootstrap-software.org/psignifit/toolbox.php

コメント
  • X
  • Facebookでシェアする
  • はてなブックマークに追加する
  • LINEでシェアする

論理演算子

2005-11-26 | MATLAB
Reference 参照
------
表示
A & B
A | A

MATLAB は、|演算子より、&演算子を優先します。MATLAB は、通常、左から右に式を計算しますが、優先順の関係で、式 a|b&c は、a|(b&c)と同じ計算になります。& と |の混在しているものに対して、ステートメントの優先順を明示的に識別するために、括弧を使うことは良い考えです。
-----

References

MATLAB Function Reference 論理演算子
コメント
  • X
  • Facebookでシェアする
  • はてなブックマークに追加する
  • LINEでシェアする