I am doing some Monte Carlo simulations and I need to generate lots of samples for calculating some quantities (call it y
) I'm interested in. The plots show y
versus the sample index (x-axis). The values usually increase/decrease in the beginning, then it tends toward an 'equilibrium value' (left one). It may also fluctuating quite a lot (right one), in which case the beginning part is not particularly bad and can be kept. What's the best way to systematically extract N samples from such data which are in the 'equilibrium value'? During my simulation, I keep generating different samples to calculate y
, so I'm looking for a method to monitor y
and stop the code once I have collected N
values of y
in the 'equilibrium' region.
Asked
Active
Viewed 62 times
-1

Physicist
- 2,848
- 8
- 33
- 62
-
1Low-pass filter? – Daniel F Feb 08 '19 at 07:00
-
@DanielF can you briefly elaborate how that may work? – Physicist Feb 08 '19 at 07:52
-
Are you able to share the data series or the function which generates the data? – newkid Feb 08 '19 at 11:54
1 Answers
0
Filter your signal. A low pass butterworth filter is a good try.
Scipy.signal has the tools you need.
This question seems related Creating lowpass filter in SciPy - understanding methods and units

Mihai Andrei
- 1,024
- 8
- 11
-
1Please don't post link-only answers. Provide an example of what you are linking to that actually answers the question. – rubenvb Feb 08 '19 at 08:35
-
1@rubenvb be fair - it's an answer to an off-topic question without a specific programming problem to solve. Over on the Data Science Stack Exchange where this belongs there isn't the expectation that answers write the implementation for you, just as here you shouldn't be asking for advice about how to interpret your data. – Will Feb 08 '19 at 09:07
-
@Will Since when is numpy/scipy off-topic here? Granted, the question could have done with some minimal code to start from (as the OP has no idea what to do). If it fits on Data Science, it also fits on Physics (which I doubt though). As stated, this is a perfectly answerable question about common programming tools and a specific problem. Also, an imperfect question is not an excuse for bad answers. – rubenvb Feb 08 '19 at 10:05
-
A filter changes the samples; it doesn't _extract_ a few of them as the OP wants – Luis Mendo Feb 08 '19 at 10:18
-
1@rubenvb tagging a question with numpy and scipy (*and* matlab) doesn't make it a question about those packages. Of course there are many specific questions about usage within all of those but "please solve my data science problem and you can code it in one of those if you like" doesn't really qualify. – Will Feb 08 '19 at 13:24