@icgio/icg-utils 1.9.2 → 1.9.4

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 +9 -0
  2. package/package.json +1 -1
package/lib/utils.js CHANGED
@@ -841,3 +841,12 @@ 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_range = (mean, std_dev, min, max) => {
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
+ let num = mean + z * std_dev
850
+ // Clip to range
851
+ return Math.max(min, Math.min(max, num))
852
+ }
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.4",
4
4
  "description": "Utils package.",
5
5
  "main": "index.js",
6
6
  "directories": {