Scientific and statistical computing in JavaScript.

Overview

Science.js

Science.js is a JavaScript library for scientific and statistical computing.

Currently, there are two modules:

  • science.stats, containing various implementations of statistical methods similar to those provided by R;
  • science.lin, for linear algebra.

Development

To help develop Science.js, you need to have Node.js and NPM installed. Once you have done that, run the following from the root directory of this repository to install the development dependencies:

make install

Thanks

I originally started this in order to add a reusable statistics module to D3.js, but now it's grown into a whole new project of its own!

The project structure and Makefile is based on that of D3, so a big thank you goes to Mike Bostock for this.

Comments
  • Choice of license?

    Choice of license?

    Hi,

    I noticed that the license page says it is copywritted. The license reads:

    Redistribution and use in source and binary forms, with or without
    modification, are permitted provided that the following conditions are met:
    
      * Redistributions of source code must retain the above copyright notice, this
        list of conditions and the following disclaimer.
    
      * Redistributions in binary form must reproduce the above copyright notice,
        this list of conditions and the following disclaimer in the documentation
        and/or other materials provided with the distribution.
    

    Does this mean that in all other packages that use this, they need to include that writing in their license?

    There are, as listed on Gitbub, 50 other packages here that use it, and some quick skimming does not list this in the few I've looked at.

    Maybe you would be willing to change to MIT or something standard?

    opened by OAGr 3
  • Loess -- Returning NaNs.

    Loess -- Returning NaNs.

    I have run into an issue with loess where, for a set of points, all the weights are becoming 0, thus leaving NaN as the result for a piece of the fit. I'm going to try to put together a simple test case.

    opened by joearasin 3
  • cleanup and change build system

    cleanup and change build system

    Hi,

    I cleaned up this repo a bit. Changes

    • dedicated build system using rollup.js
    • leads to an UMD compatible module export
    • switch to ES6 module syntax
    • fix test cornercase
    • removed test library and use CDN instead

    The resulting science object should be the same but friendlier to include by other libraries and websites

    opened by sgratzl 2
  • errors installing with npm 1.1.13 or newer

    errors installing with npm 1.1.13 or newer

    I'm getting errors using npm versions 1.1.13 or later installing science.js.

    The error starts occurring after this commit in npm: https://github.com/isaacs/npm/commit/ed2a3c1090aa4c7

    [science.js-git (master)]$ npm -v
    1.1.18
    
    [science.js-git (master)]$ npm install . -g
    npm ERR! error reading .
    npm ERR! couldn't pack . to /var/folders/zK/zK+A4xtxHSevr7D+EoIsPE+++TQ/-Tmp-/npm-1334863687383/1334863687383-0.24840772151947021/tmp.tgz
    npm ERR! Could not install: .
    
    npm ERR! SyntaxError: Unexpected token }
    npm ERR!     at Object.parse (native)
    npm ERR!     at Packer.readRules (/usr/local/lib/node_modules/npm/node_modules/fstream-npm/fstream-npm.js:179:33)
    npm ERR!     at Packer.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/fstream-npm/node_modules/fstream-ignore/ignore.js:132:22)
    npm ERR!     at [object Object].<anonymous> (fs.js:123:5)
    npm ERR!     at [object Object].emit (events.js:64:17)
    npm ERR!     at fs.js:1181:12
    npm ERR!     at Object.oncomplete (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:94:5)
    npm ERR! You may report this log at:
    npm ERR!     <http://github.com/isaacs/npm/issues>
    npm ERR! or email it to:
    npm ERR!     <[email protected]>
    npm ERR! 
    npm ERR! System Darwin 10.8.0
    npm ERR! command "node" "/usr/local/bin/npm" "install" "." "-g"
    npm ERR! cwd /Users/stephen/dev/javascript/d3/science.js-git
    npm ERR! node -v v0.6.15
    npm ERR! npm -v 1.1.18
    npm ERR! file /Users/stephen/dev/javascript/d3/science.js-git/lib/uglifyjs/package.json
    npm ERR! path /Users/stephen/dev/javascript/d3/science.js-git/lib/uglifyjs
    npm ERR! type unexpected_token
    npm ERR! fstream_path /Users/stephen/dev/javascript/d3/science.js-git/lib/uglifyjs
    npm ERR! fstream_type Directory
    npm ERR! fstream_class Packer
    npm ERR! arguments [ '}' ]
    npm ERR! message Unexpected token }
    npm ERR! fstream_stack Packer.readRules (/usr/local/lib/node_modules/npm/node_modules/fstream-npm/fstream-npm.js:182:10)
    npm ERR! fstream_stack Packer.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/fstream-npm/node_modules/fstream-ignore/ignore.js:132:22)
    npm ERR! fstream_stack [object Object].<anonymous> (fs.js:123:5)
    npm ERR! fstream_stack [object Object].emit (events.js:64:17)
    npm ERR! fstream_stack fs.js:1181:12
    npm ERR! fstream_stack Object.oncomplete (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:94:5)
    
    npm ERR! TypeError: Cannot call method 'filter' of undefined
    npm ERR!     at Packer.addIgnoreRules (/usr/local/lib/node_modules/npm/node_modules/fstream-npm/node_modules/fstream-ignore/ignore.js:148:13)
    npm ERR!     at Packer.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/fstream-npm/node_modules/fstream-ignore/ignore.js:133:10)
    npm ERR!     at [object Object].<anonymous> (fs.js:123:5)
    npm ERR!     at [object Object].emit (events.js:64:17)
    npm ERR!     at fs.js:1181:12
    npm ERR!     at Object.oncomplete (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:94:5)
    npm ERR! You may report this log at:
    npm ERR!     <http://github.com/isaacs/npm/issues>
    npm ERR! or email it to:
    npm ERR!     <[email protected]>
    npm ERR! 
    npm ERR! System Darwin 10.8.0
    npm ERR! command "node" "/usr/local/bin/npm" "install" "." "-g"
    npm ERR! cwd /Users/stephen/dev/javascript/d3/science.js-git
    npm ERR! node -v v0.6.15
    npm ERR! npm -v 1.1.18
    npm ERR! type non_object_property_call
    npm ERR! arguments [ 'filter', undefined ]
    npm ERR! message Cannot call method 'filter' of undefined
    npm ERR! 
    npm ERR! Additional logging details can be found in:
    npm ERR!     /Users/stephen/dev/javascript/d3/science.js-git/npm-debug.log
    npm not ok
    
    opened by stepheneb 2
  • Export modules for use within the node console

    Export modules for use within the node console

    With these commits, science.js can now be used within Node:

    > var s = require("./science").science
    > s
    > s.lin
    > s.stats
    

    I think they'll be useful for developing individual functions.

    opened by kitmonisit 2
  • Create a release?

    Create a release?

    I plan on using science.js in my course and it would make me happy to send the students to a release. It looks like you're already versioning science.js, so perhaps you'd be up for putting a zip file under "downloads"?

    opened by hammer 2
  • Mode of single-element arrays is null

    Mode of single-element arrays is null

    This seems incorrect:

    assert.equal(science.stats.mode([1]), 1);
    

    Fails, since it's null. If this isn't desired behavior, I can probably pull together a patch to fix.

    opened by tmcw 1
  • Add Makefile target to install dev-dependencies, like d3js

    Add Makefile target to install dev-dependencies, like d3js

    Since it is mentioned in the README that the project structure is taking after d3js. I actually find this setup much cleaner (installing node_modules in the repository directory tree).

    opened by kitmonisit 1
  • Error in initialization of hcluster

    Error in initialization of hcluster

    The code sets the linkage to "simple" when the switch only test for "single", "complete", and "average". It should be "single".

    opened by jdfekete 0
  • Actively Maintained Fork?

    Actively Maintained Fork?

    Greetings,

    It seems this repository is not maintained any longer.

    It also seems that this fork by @sgratzl is the most active one https://github.com/sgratzl/science.js

    It's published as @sgratzl/science on NPM.

    Is there any community consensus around this being the de-facto active fork? Thanks!

    opened by curran 2
  • Bump uglify-js from 2.4.24 to 3.6.1

    Bump uglify-js from 2.4.24 to 3.6.1

    Bumps uglify-js from 2.4.24 to 3.6.1.

    Release notes

    Sourced from uglify-js's releases.

    v3.6.1

     

    v3.6.0

     

    v3.5.15

     

    v3.5.14

     

    v3.5.13

     

    v3.5.12

     

    v3.5.11

     

    v3.5.10

     

    v3.5.9

     

    v3.5.8

     

    v3.5.7

     

    v3.5.6

     

    v3.5.5

     

    v3.5.4

     

    v3.5.3

     

    v3.5.2

     

    v3.5.1

     

    ... (truncated)
    Commits
    Maintainer changes

    This version was pushed to npm by alexlamsl, a new releaser for uglify-js since your current version.


    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot ignore this [patch|minor|major] version will close this PR and stop Dependabot creating any more for this minor/major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • .stats.kde() doesn't like multiple repeated values

    .stats.kde() doesn't like multiple repeated values

    I'm not sure whether this is a limitation of JS, or whether it's a bug in science.js, but when I give kde a dataset with multiple repeating values, such as:

    [394, 0, 393, 1271, 0, 640, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1159, 969, 2891, 9, 1425, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1071, 0, 592, 998, 1384, 0, 21, 1711, 341, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 141, 692, 0, 0, 0, 0, 0, 0, 0, 0, 651, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 901, 0, 0, 0, 0, 7, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 584, 0, 818, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

    or

    [68.93749237060547, 84.54015350341797, 127.1878890991211, 68.9375, 174.15017700195312, 68.9375, 68.9375, 68.9375, 68.9375, 68.9375, 68.9375, 68.9375, 68.9375, 68.9375, 68.9375, 68.9375, 68.9375, 68.9375, 147.9225311279297, 52.56502151489258, 203.442626953125, 83.44722747802734, 139.95753479003906, 68.9375, 68.9375, 68.9375, 68.9375, 68.9375, 68.9375, 68.9375, 68.93749237060547, 68.93749237060547, 68.93749237060547, 68.9375, 68.9375, 68.93749237060547, 68.93749237060547, 68.93749237060547, 68.93749237060547, 68.9375, 68.9375, 68.93749237060547, 68.93749237060547, 68.93749237060547, 68.9375, 68.93749237060547, 68.93749237060547, 68.9375, 68.9375, 68.9375, 68.9375, 68.9375, 68.93749237060547, 68.9375, 68.9375, 68.9375, 68.93749237060547, 68.9375, 68.9375, 68.9375, 68.9375, 68.9375, 68.9375, 68.9375, 160.83853149414062, 68.9375, 101.62258911132812, 112.3798828125, 124.74468231201172, 68.9375, 68.9375, 186.23104858398438, 129.73406982421875, 68.9375, 68.93749237060547, 68.9375, 68.9375, 68.9375, 68.9375, 68.9375, 68.9375, 68.9375, 68.9375, 68.93749237060547, 68.93749237060547, 68.93749237060547, 68.93749237060547, 74.37715911865234, 109.83863830566406, 68.93749237060547, 68.93749237060547, 68.93749237060547, 68.93749237060547, 68.93749237060547, 68.9375, 68.9375, 68.9375, 91.8897476196289, 68.9375, 68.9375, 68.9375, 68.9375, 68.9375, 68.9375, 68.9375, 68.9375, 68.9375, 68.9375, 68.9375, 68.9375, 68.9375, 119.34972381591797, 68.9375, 68.9375, 68.9375, 68.9375, 68.9375, 68.9375, 68.93749237060547, 68.93749237060547, 68.93749237060547, 68.93749237060547, 68.93749237060547, 68.93749237060547, 68.93749237060547, 68.93749237060547, 68.93749237060547, 68.93749237060547, 68.93749237060547, 68.93749237060547, 68.93749237060547, 68.93749237060547, 68.93749237060547, 68.93749237060547, 68.93749237060547, 68.93749237060547, 68.93749237060547, 68.93749237060547, 68.93749237060547, 68.93749237060547, 68.93749237060547, 68.93749237060547, 68.93749237060547, 68.93749237060547, 68.93749237060547, 68.93749237060547, 68.93749237060547, 68.93749237060547, 68.93749237060547, 68.93749237060547, 68.93749237060547, 68.93749237060547, 68.93749237060547, 68.93749237060547, 68.93749237060547, 68.93749237060547, 68.93749237060547, 68.93749237060547, 68.93749237060547, 68.93749237060547, 68.93749237060547, 68.93749237060547, 68.93749237060547, 68.93749237060547, 68.93749237060547, 68.93749237060547, 68.93749237060547, 57.34675216674805, 68.9375]

    or

    [1, 2, 3, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]

    I either get NaNs or 0s when evaluating the probability at a point, or a probability of greater than 1.

    opened by jamtholee 3
  • Stata Lpoly: Can this be replicated in science.js?

    Stata Lpoly: Can this be replicated in science.js?

    Before diving in head-first, great if someone can give me an indication if I am likely to succeed in mirroring Stata's Lpoly function with Science.js.

    //The Stata function:
    lpoly yVar xVar [aweight=weight_example], at(xVar) bwidth(7) gen(outputVariable)  
    

    lpoly performs a kernel-weighted local polynomial regression of yvar on xvar and displays a graph of the smoothed values with (optional) confidence bands.

    http://www.stata.com/manuals13/rlpoly.pdf

    ps. I think my main concern is about the application of weights. In the example above I am using Stata's aweight ("Analytic weights"). Is there an equivalent of this in science.js?

    Thank you!

    opened by lapidus 0
Use real-time computing technology and web technology to build a big data Kanban l to solve the problem. Among them, practical technologies include MySQL, Kafka, Flink, Redis, Flask and Echarts

实时计算(English Version) 运用实时计算技术、Web 技术构建一个大数据看板来解决问题。其中实用技术包括Mysql、Kafka、Flink、Redis、Flask和Echarts 目录 1.问题需求 2.方案分析 3.安装环境 4.环境启动命令和运行代码的方法 5.代码目录结构说明

Serendipity 2 Jan 8, 2022
For this workshop, we're going to learn more about cloud computing by exploring how to use Pulumi to build, configure, and deploy a real-life, modern application using Docker

For this workshop, we're going to learn more about cloud computing by exploring how to use Pulumi to build, configure, and deploy a real-life, modern application using Docker. We will create a frontend, a backend, and a database to deploy the Pulumipus Boba Tea Shop. Along the way, we'll learn more about how Pulumi works.

Kat Cosgrove 9 Dec 29, 2022
The cloud computing part required by the Rebage application ☁

Rebage - Cloud Computing The cloud technology used in Rebage Powered by: Google Cloud Platform, offered by Google, is a suite of cloud computing servi

Rebage Bangkit 2022 3 Sep 25, 2022
Bangkit Capstone C22-KY05 Cloud Computing

Bangkit Capstone C22-KY05 Cloud Computing This project is using Fastify as the server. Stack Node.js TypeScript Fastify Prisma PostgreSQL Cloud SQL Co

Capstone Bangkit Academy 5 Jun 13, 2022
A web application for a company that provides commercial and scientific space travel services. The application will allow users to book rockets and join selected space missions.

Space Travelers A web application for a company that provides commercial and scientific space travel services. The application will allow users to boo

Hector Torres 2 Apr 6, 2022
This web application provides commercial and scientific space travel services. The application allows users to book rockets and join selected space missions.

space-hub About Project "Space Traveler's Hub" is A web application that provides commercial and scientific space travelling services, We are working

Nicholas Emmanuel 7 Nov 2, 2022
This a web application for a company that provides commercial and scientific space travel services. The application will allow users to book rockets, dragons and join selected space missions.

Space Travelers' Hub In this project, we have worked with the real live data from the SpaceX API. Our task was to build a web application for a compan

Apuabi Titilope 4 Oct 31, 2022
In this project we built a web application that consumes an SpaceX API. It provides commercial and scientific space travel services that allows users to book rockets and join selected space missions.

Space Travelers' Hub In this project we built a web application that consumes an SpaceX API. It provides commercial and scientific space travel servic

Diego Yon 7 Sep 30, 2022
This web application provides commercial and scientific space travel services. The application allows users to book rockets and join selected space missions.

Space Traveler's Hub This web application provides commercial and scientific space travel services. The application allows users to book rockets and j

Michael Mesfin 6 Oct 4, 2022
A string of four operations of the library, can solve the js digital calculation accuracy of scientific notation and formatting problems, support for thousands of decimal point formatting output operations

A string of four operations of the library, can solve the js digital calculation accuracy of scientific notation and formatting problems, support for thousands of decimal point formatting output operations

null 10 Apr 6, 2022
This project is a web application for a company that provides commercial and scientific space travel services

Space Traveler's Hub This project is a web application for a company that provides commercial and scientific space travel services.

Selma Belhadj 5 Jun 8, 2022
This is a dummy website for company that provides commercial and scientific space travel services

This is a dummy website for company that provides commercial and scientific space travel services. This application will allow users to book rockets and join selected space missions.

David Ouma 2 Apr 14, 2022
Build a web application for a company that provides commercial and scientific space travel services

Build a web application for a company that provides commercial and scientific space travel services. The application will allow users to book rockets and join selected space missions

Abraha Kahsay 5 Aug 27, 2022
A prototype on how web3 technology can enable us to build an open, immutable, reproducible, and permanently accessible scientific record.

Web3 Research A prototype on how web3 technology can enable us to build an open, immutable, reproducible, and permanently accessible scientific record

manveer 0 Nov 27, 2022
Scientific blog template based on theaisummer.com

Scientific blog template based on AI Summer The current template can be used for scientific blogs as it supports a wide variety of necessary component

AI Summer 65 Jan 1, 2023
This is my to-do list website built with html, css and JavaScript. In this project I used Webpack to bundle JavaScript and ES6 modules to write modular JavaScript.

To-Do-List App This is my to-do list website built with html, css and JavaScript. In this project I used Webpack to bundle JavaScript and ES6 modules

Samuel Mwape 18 Sep 20, 2022
JavaScript project for the Leaderboard list app, using Webpack and ES6 features, notably modules. this app consume the Leaderboard API using JavaScript async and await and add some styling.

Leaderboard Project JavaScript project for the Leaderboard list app, using Webpack and ES6 features, notably modules. this app consume the Leaderboard

bizimungu pascal 4 May 20, 2022