mardi 11 juin 2019

How to randomly generate continuous functions

My objective is to randomly generate good looking continuous functions, good looking meaning that functions which can be recovered from their plots.

Essentially I want to generate a random time series data for 1 second with 1024 samples per second. If I randomly choose 1024 values, then the plot looks very noisy and nothing meaningful can be extracted out of it. In the end I have attached plots of two sinusoids, one with a frequency of 3Hz and another with a frequency of 100Hz. I consider 3Hz cosine as a good function because I can extract back the timeseries by looking at the plot. But the 100 Hz sinusoid is bad for me as I cant recover the timeseries from the plot. So in the above mentioned meaning of goodness of a timeseries, I want to randomly generate good looking continuos functions/timeseries.

The method I am thinking of using is as follows (python language):

(1) Choose 32 points in x-axis between 0 to 1 using x=linspace(0,1,32).

(2) For each of these 32 points choose a random value using y=np.random.rand(32).

(3) Then I need an interpolation or curve fitting method which takes as input (x,y) and outputs a continuos function which would look something like func=curve_fit(x,y)

(4) I can obtain the time seires by sampling from the func function

Following are the questions that I have:

1) What is the best curve-fitting or interpolation method that I can use. They should also be available in python.

2) Is there a better method to generate good looking functions, without using curve fitting or interpolation.

A Cosine wave with frequency of 3Hz

A Cosine wave with frequency of 100Hz




Aucun commentaire:

Enregistrer un commentaire