Python 如何在一个范围内绘制多条线?

Python 如何在一个范围内绘制多条线?,python,plot,bokeh,Python,Plot,Bokeh,只是一个好奇的初学者编程问题。我想在一个图中画出100个不同的列表。这是一个游戏,你可以选择你的起始资金和每掷一次硬币的赌注。每次硬币落在你头上,你的赌注就加倍,每次你松开,你就会松开这个赌注。有没有比定义y1到y100更简单的方法?下面的脚本是否仅定义并绘制了第一行抛硬币 我试着用bokeh图来代替matplot from bokeh.plotting import figure, show, output_file import random startcapital=int(input("

只是一个好奇的初学者编程问题。我想在一个图中画出100个不同的列表。这是一个游戏,你可以选择你的起始资金和每掷一次硬币的赌注。每次硬币落在你头上,你的赌注就加倍,每次你松开,你就会松开这个赌注。有没有比定义y1到y100更简单的方法?下面的脚本是否仅定义并绘制了第一行抛硬币

我试着用bokeh图来代替matplot

from bokeh.plotting import figure, show, output_file
import random
startcapital=int(input("What's the start capital?:"))
bet=int(input("What's the stakes?:"))
ioutcome=[]
outcome=[]
for i in range (100):
outcomei=[]
for i in range(10):
    i=random.randint(0,1)
    ioutcome.append(i)
    if startcapital>0:
        if i==1:
            startcapital+=bet
        if i==0:
            startcapital-=bet
    outcomei.append(startcapital)
outcome.append(outcomei)
x=[1,2,3,4,5,6,7,8,9,10]
y=outcome[1]
p = figure(plot_width=800, plot_height=400)
p.line(x, y, line_width=2)
show(p)

使用numpy,避免for循环。阅读

将numpy导入为np
形状=(10,)
开始=np.ones(形状)
rnd=np.随机.随机样本(形状)
开始[rnd>0.5]*=2.0

开始[rnd使用numpy,避免for循环。阅读

将numpy导入为np
形状=(10,)
开始=np.ones(形状)
rnd=np.随机.随机样本(形状)
开始[rnd>0.5]*=2.0
开始[rnd
import numpy as np

shape = (10,)

start = np.ones(shape)

rnd = np.random.random_sample(shape)

start[rnd > 0.5] *= 2.0
start[rnd <= 0.5] = 0.0

print(start)