Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
discrete-sampling
Advanced tools
JavaScript for sampling from a handful of discrete probability distributions
JavaScript for sampling from a handful of discrete probability distributions
This is now a node module on npm. To install, go to your project's directory in
a terminal and enter
npm install discrete-sampling
To load the library in your own node module, use
var SJS = Sampling = require('discrete-sampling');
To load the module in the browser, you can load the script with
<script src="node_modules/discrete-sampling/dist/discrete.js"></script>
and then the library will be accessible through the global variables SJS
and
Sampling
.
var bern = Sampling.Bernoulli(.5);
bern.draw(); // One random draw
bern.sample(10); // Get an array of 10 samples.
var binom = SJS.Binomial(10, 0.5); // alternate syntax (Sampling === SJS)
binom.draw();
binom.sample(10);
var probabilities = [.1, .2, .3, .05, .15];
var disc = SJS.Discrete(probabilities);
disc.draw();
disc.sample(10);
// The probabilities will be normalized for you.
var probs = [1,1,1,1,1,1,1,1,1,1,1,1,1,1]
var mult = SJS.Multinomial(5, probs);
mult.draw();
mult.sample(10);
var myArray = [0,1,2,3,4,5]
// sample five elements with replacement
sample_from_array(myArray, 5, true)
// sample five elements without replacement
sample_from_array(myArray, 5)
FAQs
JavaScript for sampling from a handful of discrete probability distributions
We found that discrete-sampling demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.