Last active
August 29, 2015 14:02
-
-
Save fnielsen/efe0becb61729f1aa31a to your computer and use it in GitHub Desktop.
Self-referential implication
This file contains hidden or 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
from math import exp | |
import numpy as np | |
import matplotlib.pyplot as plt | |
def sigmoid(x): | |
return 1.0 / (1.0 + exp(-x)) | |
def implication(a, b): | |
if (-0.5 * a + 1.0 * b) > -0.5: | |
return 1.0 | |
else: | |
return 0.0 | |
def soft_implication(a, b): | |
return -0.5 * a + 1.0 * b + 0.5 | |
def sigmoid_implication(a, b): | |
return sigmoid(-0.5 * a + 1.0 * b - 0.5) | |
plt.figure() | |
for n in range(4): | |
plt.subplot(2, 2, n+1) | |
a = n // 2 | |
b = n % 2 | |
aa = [a] | |
a0 = a | |
for n in range(20): | |
a = soft_implication(a, b) | |
aa.append(a) | |
plt.plot(aa, linewidth=3.0) | |
plt.title('a = %d, b = %d' % (a0, b,)) | |
plt.ylim(0, 2.) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment