kitty
kitty

Reputation: 75

How to randomly generate (x, y) points following a linear equation?

I have a equation y=9x+6. I want to extract 10 random points from this function. How should I proceed?

Upvotes: 0

Views: 731

Answers (1)

Ramiro Magno
Ramiro Magno

Reputation: 3175

Generate 10 random x-values, in this example uniformly distributed (function runif), and then calculate the corresponding y-values following your equation.

You can control the x-range by setting different min and max parameters to function runif.

x <- runif(10, min = 0, max = 1)
y <- 9*x+6
plot(x,y)

Upvotes: 5

Related Questions