Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Plotting a Function With Noise

I always wondered how such pictures are made:

enter image description here

I am working with the R programming language. I would like to plot a parabola with "random noise" added to the parabola. I tried something like this:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

x = 1:100
y = x^2
z = y + rnorm(1, 100,100)

plot(x,z)

enter image description here

But this is still producing a parabola without "noise".

Can someone please show me how I can add "noise" to a parabola (or any function) in R?

Thanks!

>Solution :

In this case you need to generate 100 random points or will be adding the same amount of noise to each point (thus no noise). z = y + rnorm(100, 100,100)

x = 1:100
y = x^2
z = y + rnorm(length(y), 100,100)

plot(x,z)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading