Python Forum
Why there is a star inside randn?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why there is a star inside randn?
#1
Hi, I have question about generating a linear model from random data. I suppose that by default, the value of size in the dnorm function is one. When this function is called with N=100, size becomes 100. Am I correct? If so, what is the reason for having the * symbol in np.randn(*size)? What is the different between this and np.randn(size)?

def dnorm(mean, variance, size=1):
  if isinstance(size, int):
      size = size,
  return mean + np.sqrt(variable) * np.random.randn(*size)

N = 100
X = np.c_[dnorm(0, 0.4, size=N),
          dnorm(0, 0.6, size=N)]
Reply


Messages In This Thread
Why there is a star inside randn? - by new_to_python - Mar-04-2020, 01:02 AM
RE: Why there is a star inside randn? - by scidam - Mar-04-2020, 11:40 AM
RE: Why there is a star inside randn? - by scidam - Mar-05-2020, 11:49 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Turtle Star Fill Color Yellow-White Interchanging Color Effect codelab 9 1,043 Oct-25-2023, 09:09 AM
Last Post: codelab
  fpdf star character issue KatMac 3 3,009 May-01-2021, 06:22 PM
Last Post: KatMac
  How to scrape and count star rating using Selenium and Python? celinafregoso99 1 3,323 Feb-15-2021, 02:45 PM
Last Post: kashcode
  Optimisation problem - star identification pberrett 1 2,262 Apr-01-2019, 12:17 AM
Last Post: scidam

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020