Skip to content

Instantly share code, notes, and snippets.

@mmmayo13
Last active April 26, 2020 05:01
Show Gist options
  • Select an option

  • Save mmmayo13/5b99eece97cbf9e94d4d37e1621ea1fd to your computer and use it in GitHub Desktop.

Select an option

Save mmmayo13/5b99eece97cbf9e94d4d37e1621ea1fd to your computer and use it in GitHub Desktop.

Revisions

  1. mmmayo13 renamed this gist Apr 4, 2017. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions standard-dev-.py → standard-dev-outliers.py
    Original file line number Diff line number Diff line change
    @@ -7,6 +7,6 @@
    mean = numpy.mean(elements, axis=0)
    sd = numpy.std(elements, axis=0)

    final_list = [x for x in arr if (x > mean - 2 * sd)]
    final_list = [x for x in final_list if (x < mean + 2 * sd)]
    final_list = [x for x in arr if (x > mean - 2 * sd)]
    final_list = [x for x in final_list if (x < mean + 2 * sd)]
    print(final_list)
  2. mmmayo13 created this gist Feb 2, 2017.
    12 changes: 12 additions & 0 deletions standard-dev-.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    import numpy

    arr = [10, 386, 479, 627, 20, 523, 482, 483, 542, 699, 535, 617, 577, 471, 615, 583, 441, 562, 563, 527, 453, 530, 433, 541, 585, 704, 443, 569, 430, 637, 331, 511, 552, 496, 484, 566, 554, 472, 335, 440, 579, 341, 545, 615, 548, 604, 439, 556, 442, 461, 624, 611, 444, 578, 405, 487, 490, 496, 398, 512, 422, 455, 449, 432, 607, 679, 434, 597, 639, 565, 415, 486, 668, 414, 665, 763, 557, 304, 404, 454, 689, 610, 483, 441, 657, 590, 492, 476, 437, 483, 529, 363, 711, 543]

    elements = numpy.array(arr)

    mean = numpy.mean(elements, axis=0)
    sd = numpy.std(elements, axis=0)

    final_list = [x for x in arr if (x &gt; mean - 2 * sd)]
    final_list = [x for x in final_list if (x &lt; mean + 2 * sd)]
    print(final_list)