@icgio/icg-utils 1.9.2 → 1.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/utils.js +7 -0
  2. package/package.json +1 -1
package/lib/utils.js CHANGED
@@ -841,3 +841,10 @@ module.exports.exchange_basecur_curs_converter = (exchange_basecur_curs) => {
841
841
  module.exports.sort_keys = (dict) => {
842
842
  return _.fromPairs(_.sortBy(_.toPairs(dict), (e) => e[0]))
843
843
  }
844
+
845
+ module.exports.random_normal = (mean, std_dev) => {
846
+ let u = 1 - Math.random() // [0,1) -> (0,1]
847
+ let v = Math.random()
848
+ let z = Math.sqrt(-2.0 * Math.log(u)) * Math.cos(2.0 * Math.PI * v) // Box-Muller Transform
849
+ return mean + z * std_dev
850
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@icgio/icg-utils",
3
- "version": "1.9.2",
3
+ "version": "1.9.3",
4
4
  "description": "Utils package.",
5
5
  "main": "index.js",
6
6
  "directories": {