1
$\begingroup$

I have the following:

m = 6.137*10^-13; k = 1.5*m; 
stddev = Sqrt[2*k]*Sqrt[m];
whiteNoise = WhiteNoiseProcess[stddev]

How can I produce a function that gives me for each call a single random value from WhiteNoiseProcess?

I tried the following which seems to me not very clever:

getValue[time_] := Module[
   {t = time},
   data = RandomFunction[whiteNoise, {t, t + 1}];
   data[[2, 1, 1, 1]]
];

getValue[1]

1.64153*10^-12

I need for the upper case something similar like this:

For a NormalDistribution:

I could simply write: getValue[time_] := RandomVariate[NormalDistribution[0, 1]]

This returns also a value for real numbers which does not work with my example.

getValue[0.1]

-0.545294

getValue[1]

0.327526
$\endgroup$
  • 1
    $\begingroup$ You could do RandomFunction[whiteNoise, {t, t + 1}]["FirstValue"]. $\endgroup$ – J. M. will be back soon Mar 28 '18 at 14:18
  • $\begingroup$ @J. M. Thanks. So there is no other solution than picking the first one from 2 (or more) values? $\endgroup$ – mrz Mar 29 '18 at 8:22
  • $\begingroup$ I don't really know; that's why I didn't give an answer yet. $\endgroup$ – J. M. will be back soon Mar 29 '18 at 8:26
1
$\begingroup$
ClearAll[getV];
getV[t_Integer]:= RandomVariate[whiteNoise[t]]  

With a common random seed getV produces the same output as OP's getValue:

SeedRandom[1] 
res1 = getValue /@ Range[10];
SeedRandom[1] 
res2 = getV /@ Range[10]; 
res1 == res2

True

$\endgroup$
  • $\begingroup$ Thanks a lot for your solution. $\endgroup$ – mrz Apr 5 '18 at 14:39
  • $\begingroup$ @Lenoil, my pleasure. Thank you for the accept. $\endgroup$ – kglr Apr 5 '18 at 14:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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