Last active
August 6, 2017 23:55
-
-
Save randcode-generator/55ca5430c1126a3efaf128c696d4026f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tensorflow as tf | |
import numpy as np | |
tf.set_random_seed(100) | |
stddev = 0.5 | |
numOfValues = 100000 | |
normal = tf.Variable(tf.random_normal([1,numOfValues], stddev = stddev)) | |
init_op = tf.global_variables_initializer() | |
with tf.Session() as sess: | |
sess.run(init_op) | |
normalArr = normal.eval() | |
oneSTDDEV = 0.0 | |
twoSTDDEV = 0.0 | |
threeSTDDEV = 0.0 | |
fourSTDDEV = 0.0 | |
fiveSTDDEV = 0.0 | |
for x in np.nditer(normalArr): | |
if x < stddev and x > -stddev: | |
oneSTDDEV += 1 | |
elif x < 2*stddev and x > 2*-stddev: | |
twoSTDDEV += 1 | |
elif x < 3*stddev and x > 3*-stddev: | |
threeSTDDEV += 1 | |
elif x < 4*stddev and x > 4*-stddev: | |
fourSTDDEV += 1 | |
elif x < 5*stddev and x > 5*-stddev: | |
fiveSTDDEV += 1 | |
else: | |
print("Wow, above 5 standard deviations") | |
print("1 std: {0}, {1}".format(oneSTDDEV, oneSTDDEV/numOfValues)) | |
print("2 std: {0}, {1}".format(twoSTDDEV, twoSTDDEV/numOfValues)) | |
print("3 std: {0}, {1}".format(threeSTDDEV, threeSTDDEV/numOfValues)) | |
print("4 std: {0}, {1}".format(fourSTDDEV, fourSTDDEV/numOfValues)) | |
print("5 std: {0}, {1}".format(fiveSTDDEV, fiveSTDDEV/numOfValues)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment