Skip to content

Instantly share code, notes, and snippets.

@YujiSODE
YujiSODE / statistics-distributions.js
Created July 21, 2016 06:25 — forked from Robsteranium/statistics-distributions.js
JavaScript library for calculating critical values and upper probabilities of common statistical distributions
/*
* NAME
*
* statistics-distributions.js - JavaScript library for calculating
* critical values and upper probabilities of common statistical
* distributions
*
* SYNOPSIS
*
*
@YujiSODE
YujiSODE / stRank.js
Last active June 17, 2017 01:44
the function returns a rank object available for the statistical rank test, by a given array A.
/*stRank.js
*
* Copyright (c) 2017 Yuji SODE <yuji.sode@gmail.com>
*
* This software is released under the MIT License.
*/
//it returns a rank object available for the statistical rank test, by a given array A.
/*
* A=[a0, ..., an]; the all aj in A is numerical data.
* rank of x: O.x=[rank,count,true rank].
@YujiSODE
YujiSODE / uCal.js
Last active August 2, 2016 10:33
It returns value of u for Mann–Whitney U test.
/*it returns value of u estimated with two given array: A and B, for Mann–Whitney U test.
* returned value is [u, u approximated with standard normal distribution, the maximum sample size].
* reference:
* Mann, H. B., and Whitney, D. R. 1947. On a Test of Whether one of Two Random Variables is Stochastically Larger than the Other. Ann. Math. Statist. vol. 18 , no. 1, p. 50-60.
*/
var uCal=function(A,B){
//A=[a0, ..., an] and B=[b0, ..., bn]; the all element in both Arrays is numerical data.
var slf=this.window,C=[],R2=0,I=0,u=0,u1=0,u2=0,n1=A.length,n2=B.length,Obj;
//------------------------------------------------------
//it returns a rank object available for the statistical rank test, by a given array A.
@YujiSODE
YujiSODE / csv2GnuplotData.js
Created September 20, 2016 11:01
it converts csv formatted text data into tab separated data for gnuplot.
//csv2GnuplotData.js
//it converts csv formatted text data into tab separated data for gnuplot
function csv2GnuplotData(title,csv){
var slf=this.window,_csvD=csv.split(/,/),N=_csvD.length,I=0,txt='#'+title+'\n'+'#N='+N+'\n';
var saveD=function(a){slf.location.href='data:application/octet-stream,'+encodeURIComponent(a);};
while(I<N){txt+=I+'\t'+_csvD[I]+'\n',I+=1;}
txt+='#EOF';
saveD(txt);
}
/* Copyright (c) 2016 Yuji SODE <yuji.sode@gmail.com>
@YujiSODE
YujiSODE / touch2MouseEvt.js
Last active January 17, 2017 16:50
function simulates mouse event via touch event.
//touch2MouseEvt.js
//Copyright (c) 2017 Yuji SODE <yuji.sode@gmail.com>
//this function simulates mouse event via touch event.
function touch2MouseEvt(e){
//e is event object
e.preventDefault();
if(!!e.changedTouches&&e.changedTouches.length>0){
var touch0=null,
/*function simulates new mouse event*/
newMEvt=function(EventName,tObj,tgt){
@YujiSODE
YujiSODE / multiCount.js
Created February 14, 2017 07:23
Function returns function for multiple count.
//multiCount.js
//this function returns function for multiple count
function multiCount(){
//n is integer, no less than 0
var mC=function(n){
//n is integer, no less than 0
if(+n<0){throw new Error('n<0');}
mC.c[n]=(mC.c[n]!==undefined)?mC.c[n]+1:1;
return mC.c;
};
@YujiSODE
YujiSODE / touchEvt2mouseEvt.js
Created February 28, 2017 08:52
function simulates mouse event via touch event.
//touchEvt2mouseEvt.js
//Copyright (c) 2017 Yuji SODE <yuji.sode@gmail.com>
//Handling clicks with touch event
(function(){
var slf=window,events=['touchstart','touchmove','touchend'],i=0,n=events.length,
/*this function simulates mouse event via touch event*/
touch2MouseEvt=function(e){
//e is event object
e.preventDefault();
if(!!e.changedTouches&&e.changedTouches.length>0){
@YujiSODE
YujiSODE / jsciTest.java
Created April 15, 2017 02:10
critical values (p=0.05) for F-distribution with JSci
/*=== JSci version 1.2: F-distribution ===
F(5,20)|p=0.95:2.7108898372096952
F(3,60)|p=0.95:2.7580782958425782
F(3,116)|p=0.95:2.6828094071219026
F(3,120)|p=0.95:2.680167569850269
/*=== JSci ===*/
@YujiSODE
YujiSODE / canvasFrm.html
Last active May 15, 2017 14:06
Simple HTML framework using two canvas tags.
<!-- canvasFrm.html -->
<!-- Simple HTML framework using two canvas tags. -->
<!DOCTYPE html><html lang='en'>
<head>
<meta charset='utf-8'>
<title>canvasFrm</title>
<style type='text/css'>canvas{border:1px solid #000f;}</style>
</head>
<body>
<div>
@YujiSODE
YujiSODE / nXmGen.js
Created May 29, 2017 10:59
function returns array formatted random n x m data map.
/*nXmGen.js
*
* Copyright (c) 2017 Yuji SODE <yuji.sode@gmail.com>
*
* This software is released under the MIT License.
*/
//function returns array formatted random n x m data map.
/*
* e.g., random 3 x 3 data map = ["010","111","101"]
* - n: data map width