2021年4月24日星期六

Numpy 2d dataset with xi and yi

I am new to numpy therefore I have a basic question to ask. Here is the problem:

  • Please create a 2D dataset {(x1; y1), (x2; y2), ... , (x100; y100)}, where each dimension of xi is sampled from a standard normal distribution. Define yi = 0 if ||xi||^2 < 1, else yi = 1. The seed should be set to 42*

my question is is ||xi|| the norm of xi? if so isnt it just one number? how do i create a set of yi? when I try to print yi only one number comes out.. Thanks for your help. I know I'm wrong but how can I fix it? how to create this 2d dataset? here is my code:

rNumber = 4  xi=np.random.standard_normal(rNumber)  print(xi)    if np.linalg.norm(xi)**2 <1:      yi=0    else:      yi=1  print(yi)```  
https://stackoverflow.com/questions/67249524/numpy-2d-dataset-with-xi-and-yi April 25, 2021 at 11:34AM

没有评论:

发表评论