New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@bdelab/jscat

Package Overview
Dependencies
Maintainers
2
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bdelab/jscat - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

13

lib/index.d.ts

@@ -19,2 +19,9 @@ export declare type Zeta = {

/**
* a 3PL Fisher information function
* @param theta - ability estimate
* @param zeta - item params
* @returns {number} - the expected value of the observed information
*/
export declare const fisherInformation: (theta: number, zeta: Zeta) => number;
/**
* return a Gaussian distribution within a given range

@@ -54,1 +61,7 @@ * @param mean

} | undefined;
/**
* calculate the standard error of mean of ability estimation
* @param theta
* @param zetas
*/
export declare const SEM: (theta: number, zetas: Array<Zeta>) => number;

46

lib/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.findNextItem = exports.estimateAbility = exports.abilityPrior = exports.normal = exports.itemResponseFunction = void 0;
exports.SEM = exports.findNextItem = exports.estimateAbility = exports.abilityPrior = exports.normal = exports.fisherInformation = exports.itemResponseFunction = void 0;
const optimization_js_1 = require("optimization-js");

@@ -17,2 +17,14 @@ const lodash_1 = require("lodash");

/**
* a 3PL Fisher information function
* @param theta - ability estimate
* @param zeta - item params
* @returns {number} - the expected value of the observed information
*/
const fisherInformation = (theta, zeta) => {
const p = (0, exports.itemResponseFunction)(theta, zeta);
const q = 1 - p;
return Math.pow(zeta.a, 2) * (q / p) * (Math.pow(p - zeta.c, 2) / Math.pow(1 - zeta.c, 2));
};
exports.fisherInformation = fisherInformation;
/**
* return a Gaussian distribution within a given range

@@ -63,9 +75,7 @@ * @param mean

let nf = 0;
for (let i = 0; i < prior.length; i++) {
const theta = prior[i][0];
const probability = prior[i][1];
prior.forEach(([theta, probability]) => {
const like = likelihood(theta);
num += theta * like * probability;
nf += like * probability;
}
});
return num / nf;

@@ -121,3 +131,3 @@ }

if (method === 'mfi') {
const stimuliAddFisher = arr.map((element) => (Object.assign({ fisherInformation: fisherInformation(theta, { a: 1, b: element.difficulty, c: 0.5, d: 1 }) }, element)));
const stimuliAddFisher = arr.map((element) => (Object.assign({ fisherInformation: (0, exports.fisherInformation)(theta, { a: 1, b: element.difficulty, c: 0.5, d: 1 }) }, element)));
stimuliAddFisher.sort((a, b) => b.fisherInformation - a.fisherInformation);

@@ -211,14 +221,16 @@ stimuliAddFisher.forEach((stimulus) => {

}
/**
* a 3PL Fisher information function
* @param theta - ability estimate
* @param zeta - item params
* @returns {number} - the expected value of the observed information
*/
function fisherInformation(theta, zeta) {
const p = (0, exports.itemResponseFunction)(theta, zeta);
const q = 1 - p;
return Math.pow(zeta.a, 2) * (q / p) * ((p - zeta.c) / Math.pow(1 - zeta.c, 2));
}
};
exports.findNextItem = findNextItem;
/**
* calculate the standard error of mean of ability estimation
* @param theta
* @param zetas
*/
const SEM = (theta, zetas) => {
let sum = 0;
zetas.forEach(function (zeta) {
sum += (0, exports.fisherInformation)(theta, zeta);
});
return 1 / Math.sqrt(sum);
};
exports.SEM = SEM;
{
"name": "@bdelab/jscat",
"version": "1.0.3",
"version": "1.0.4",
"description": "A library to support IRT-based computer adaptive testing in JavaScript",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -12,3 +12,3 @@ # jsCAT: Computer Adaptive Testing in JavaScript

```JavaScript
import {normal, estimateAbility, findNextItem} from '@bdelab/jscat';
import {normal, estimateAbility, findNextItem, SEM} from '@bdelab/jscat';

@@ -21,2 +21,4 @@ // declare prior if you choose to use EAP method

const se = SEM(theta, zetas);
const nextStimulus = findNextItem(stimuli, theta, method, deepCopy);

@@ -23,0 +25,0 @@ ```

@@ -1,4 +0,2 @@

import { itemResponseFunction } from '../index';
import { estimateAbility } from '../index';
import { findNextItem } from '../index';
import { itemResponseFunction, estimateAbility, findNextItem, SEM } from '../index';
import { Stimulus } from '../index';

@@ -54,1 +52,15 @@

});
describe('SEM', () => {
it('correctly calculate the standard error of mean of ability estimate', () => {
const received = SEM(-1.551, [
{ a: 1, b: -0.4473004, c: 0.5, d: 1 },
{ a: 1, b: 2.8692, c: 0.5, d: 1 },
{ a: 1, b: -0.46935, c: 0.5, d: 1 },
{ a: 1, b: -0.5758, c: 0.5, d: 1 },
{ a: 1, b: -1.43012, c: 0.5, d: 1 },
{ a: 1, b: -1.60728, c: 0.5, d: 1 },
]);
expect(1.88).toBeCloseTo(received, 2);
});
});

@@ -23,2 +23,14 @@ import { minimize_Powell } from 'optimization-js';

/**
* a 3PL Fisher information function
* @param theta - ability estimate
* @param zeta - item params
* @returns {number} - the expected value of the observed information
*/
export const fisherInformation = (theta: number, zeta: Zeta) => {
const p = itemResponseFunction(theta, zeta);
const q = 1 - p;
return Math.pow(zeta.a, 2) * (q / p) * (Math.pow(p - zeta.c, 2) / Math.pow(1 - zeta.c, 2));
};
/**
* return a Gaussian distribution within a given range

@@ -78,9 +90,7 @@ * @param mean

let nf = 0;
for (let i = 0; i < prior.length; i++) {
const theta = prior[i][0];
const probability = prior[i][1];
prior.forEach(([theta, probability]) => {
const like = likelihood(theta);
num += theta * like * probability;
nf += like * probability;
}
});
return num / nf;

@@ -226,14 +236,15 @@ }

}
};
/**
* a 3PL Fisher information function
* @param theta - ability estimate
* @param zeta - item params
* @returns {number} - the expected value of the observed information
*/
function fisherInformation(theta: number, zeta: Zeta) {
const p = itemResponseFunction(theta, zeta);
const q = 1 - p;
return Math.pow(zeta.a, 2) * (q / p) * ((p - zeta.c) / Math.pow(1 - zeta.c, 2));
}
/**
* calculate the standard error of mean of ability estimation
* @param theta
* @param zetas
*/
export const SEM = (theta: number, zetas: Array<Zeta>) => {
let sum = 0;
zetas.forEach(function (zeta) {
sum += fisherInformation(theta, zeta);
});
return 1 / Math.sqrt(sum);
};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc