Why are my plots printing out of order?
Here is my code:
def lam(n):
m = 1
while (n+1 - m >= 0):
m = 2*m
return m/2
def inter(n,l):
return [(n+1-l)/l, (n+2 - l)/l]
def f(a,b,x):
if x>=a and x<=b:
return 1
else:
return 0
for n in range(1,15):
I = inter(n,lam(n))
lst = []
for i in range(101):
lst.append([i/100, f(I[0],I[1],i/100)])
scatter_plot(lst,markersize=20,aspect_ratio=0.1)
I know that the plots are printing correctly, they are just out of order for some reason. Any ideas?
Also, I know this is a terrible way to plot this. I wanted to use:
plot(f(I[0],I[1],x),(x,0,1))
but that doesn't seem to be working (it just gives me the zero function), so if you have any suggestions for that as well, that would be great. Thank you.
For reference, can you mention what interface (command-line, sagenb, Jupyter notebook, CoCalc Sage worksheet) you are using? It's conceivable the answer may be different depending on this.