I am struggling to define and and plot the following function:

$\qquad \sin(x) + 0.15\,u$

where u is a uniform random variable in the range [-1, 1].

How can I define such a function and then plot it for $x$ over the range [0, 500]?

closed as unclear what you're asking by Pillsy, Sektor, JimB, N.J.Evans, gwr Nov 9 at 22:57

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Take a look at UniformDistribution and TransformedDistribution. I think it may help you. – Gustavo Delfino Nov 8 at 18:29
  • 2
    This is not really a well-defined problem. You are wanting to plot a realisation of a random process. Do you have one value of u for all values of x? Or do you have an independent value of u for every real value of x? If the latter, when you plot it (at any resolution) you will only see a vertical bar around the curve. – mikado Nov 8 at 19:31

You can define a function with randomness almost exactly like defining a regular (deterministic) function:

f[x_] := Sin[x] + 0.15*RandomVariate[UniformDistribution[{-1, 1}]];
Plot[f[x], {x, 0, 10}]

enter image description here

Between 0 and 500:

Plot[f[x], {x, 0, 500}]

enter image description here

SeedRandom[0]

data = Table[{x, 
    Sin[x] + 0.15*RandomVariate[UniformDistribution[{-1, 1}]]}, {x, 0,
     500, 0.25}];

ListLinePlot[data, Frame -> True, ImageSize -> Large]

enter image description here

Not the answer you're looking for? Browse other questions tagged or ask your own question.