我正在尝试创建一个函数,它将一个 numpy dstr 名称作为参数并绘制来自该分布的随机数据点的直方图。
如果它仅适用于需要 1 个参数的 npy 发行版,那就可以了。只是真的坚持尝试创建 np.random.distribution()... \
# import libraries
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
#Define a function (Fnc) that produces random numpy distributions (dstr)
#Fnc args: [npy dstr name as lst of str], [num of data pts]
def get_rand_dstr(dstr_name):
npdstr = dstr_name
dstr = np.random.npdstr(user.input("How many datapoints?"))
#here pass each dstr from dstr_name through for loop
#for loop will prompt user for required args of dstr (nbr of desired datapoints)
return plt.hist(df)
get_rand_dstr('chisquare')