Skip to content

Instantly share code, notes, and snippets.

@cesarvargas00
Created July 16, 2021 19:41
Show Gist options
  • Select an option

  • Save cesarvargas00/11a0a9e4f0a8c3397aaba30edc2d53fd to your computer and use it in GitHub Desktop.

Select an option

Save cesarvargas00/11a0a9e4f0a8c3397aaba30edc2d53fd to your computer and use it in GitHub Desktop.

Revisions

  1. cesarvargas00 created this gist Jul 16, 2021.
    15 changes: 15 additions & 0 deletions question.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    function empirical(x, y, n){
    for (let i = 0; i < n; i++){
    x = x * (1 + (Math.random() < .5 ? -1 : 1) * (Math.random() * y)/x)
    }
    return x
    }


    let xs = []
    for (let i = 0; i < 10000; i++){
    xs.push(empirical(100, 1, 10000)
    )
    }

    xs.reduce((acc, x) => acc + x,0)/xs.length