2
$\begingroup$

Let's assume that I have some particular signal on the finite time interval which is described by function $f(t)$. It could be, for instance, a rectangular pulse with amplitude $a$ and period T; Gauss function with $\sigma$ and $a$ or something else.

Now I need to generate a signal which consists from randomly appearing functions $f(t)$ with random parameters (random parameters should be random in some specified range). If $f(t)$ is a rectangular function, the generated signal should consist from randomly generated rectangles appearing on random moments of time (rectangles should not overlap). Can anyone suggest what is the best way to do it in Mathematica?

Example:rectangles

$\endgroup$
  • $\begingroup$ if you can provide a picture of what you want, it will be good. $\endgroup$ – Algohi May 29 '14 at 15:17
  • 2
    $\begingroup$ You say if the pulses are rectangular then they should not overlap, which is fine. But what is the analogous condition for Gaussians, which have infinite support and so always overlap? $\endgroup$ – Rahul May 29 '14 at 17:39
1
$\begingroup$

I did not get your question correctly but here is want I can give you:

if f is a function defined as follows:

 f = 
     PDF[NormalDistribution[3.5, .8], x] + PDF[NormalDistribution[6, 1], x]

(*    
0.498678 E^(-0.78125 (-3.5 + x)^2) + E^(-(1/
       2) (-6 + x)^2)/Sqrt[2 \[Pi]]
*)

data1 = Table[
  PDF[NormalDistribution[3.5, .8], i] + 
   PDF[NormalDistribution[6, 1], i], {i, -5, 15, .01}]; noise = 
 RandomReal /@ RandomReal[{-0.2, .2}, Length[data1]]; data2 = 
 data1 + noise;

if data1 and data are plotted, plot will looks like follows: enter image description here

$\endgroup$
1
$\begingroup$

Assuming the non-overlap is a hard constraint, you can use TruncatedDistribution[] to get what you want. Over some range, say {0,20} generate some non-overlapping intervals.

intervals = Partition[Sort@RandomReal[{0, 20}, 10], 2]

Now use the intervals to make a list of TruncatedDistribution[]. Pick your distribution to be truncated, here I chose NormalDistributions centered on the intervals with random variance.

distList = Map[TruncatedDistribution[#, NormalDistribution[(#[[1]] + #[[2]])/2, RandomReal[{.1, 2}]]] &, intervals]

Look at the PDFs in a plot.

pdfList = Map[PDF[#, x] &, distList]
Plot[pdfList, {x, 0, 20}, PlotRange -> All]

enter image description here

This plots the individual PDFs. To merge them...

Plot[pdfList // Total, {x, 0, 20}, PlotRange -> All]

enter image description here

$\endgroup$

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.