mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-13 09:08:13 +00:00
30 lines
800 B
JavaScript
30 lines
800 B
JavaScript
require('../jspsych.js');
|
|
|
|
var data = [
|
|
{rt: 100},
|
|
{rt: 200},
|
|
{rt: 300},
|
|
{rt: 400},
|
|
{rt: 500}
|
|
];
|
|
|
|
jsPsych.data._customInsert(data);
|
|
|
|
describe('DataCollection', function(){
|
|
test('#mean', function(){
|
|
expect(jsPsych.data.getData().select('rt').mean()).toBe(300);
|
|
});
|
|
test('#count', function(){
|
|
expect(jsPsych.data.getData().select('rt').count()).toBe(5);
|
|
});
|
|
test('#sd', function(){
|
|
expect(jsPsych.data.getData().select('rt').sd()).toBe(Math.sqrt((Math.pow(200,2)+Math.pow(100,2)+Math.pow(100,2)+Math.pow(200,2))/5));
|
|
});
|
|
test('#median', function(){
|
|
expect(jsPsych.data.getData().select('rt').median()).toBe(300);
|
|
});
|
|
test('#subset', function(){
|
|
expect(jsPsych.data.getData().select('rt').subset(function(x){ return x > 300; }).count()).toBe(2);
|
|
})
|
|
});
|