This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

About fluctuating sampling rate
#1
Hi, thank you for making a great app!
I am doing the Acceleration Spectrum experiment with an iPhone 12 Pro Max (whose accelermoter's sampling rate is at 100Hz).
Since I want to limit the sampling rate to another number, I changed a bit in the code.
- <input>
    <sensor type="accelerometer" rate="0">  # I changed to 50 and 80

I succeeded in loading the experiment to my phone already.
However, there were some strange things:
- For the 50Hz case: Sometimes the sampling rate starts at 33Hz and then slowly reaching 45 Hz and fluctuates; sometimes it starts perfectly at 50Hz and does not change at all
- For the 80Hz case: The sampling rate is always at 50Hz

I would really appreciate it if you could let me know what the reasons might be.
And maybe a way to fix?

Thank you for your time!
Reply
#2
The problem is that there is no guaranteed method to request a specific sampling rate from the operating system. Phyphox knows about three strategies to achieve a target sampling rate:

Copied and slightly modified from our Wiki:

request
The target rate is directly requested from the system and the provided sensor data will be provided as is. It depends on the system if the provided rate is close to the requested one and the system might not be able to provide sensor data at given rates or it might decide to provide a different rate if the sensor data is shared with other apps. This strategy is most likely to yield a rate that strongly differs from the expected one, but as it will not group or discard data points, it will not introduce additional sampling or aliasing effects.

generate
The target rate is generated internally by phyphox while requesting the highest possible rate from the system. It is guaranteed to give data points at the desired rate and can even exceed the sensor rate (be careful not to waste performance with this). While the resulting data points seem very easy to interpret afterwards and while it makes it easy to synchronize different sensors, this strategy can severely degrade the recorded sensor data as data points might be duplicated or discarded in unforeseen patterns. If the target rate is close to the actual internal sensor rate, this will very likely introduce additional sampling effects like aliasing between the sensors sample rate and this target rate. Therefore, this strategy is recommended for educational purposes to simplify data analysis, but if you know how to analyze data and want the best possible data quality, it is highly recommended to use the request strategy instead as you can emulate the generate strategy in your data analysis later, but you could not go back to the quality of "request" from "generate" data.

limit
The maximum sensor rate is requested by the system and the setting of rate is used as a limiter. More precisely, phyphox generates a new data point whenever the time interval from the last data point to the latest sensor event exceeds 1/rate. The resulting rate will always be close to but lower than the requested rate and the actual rate strongly depends on the actual sensor rate. This strategy is a compromise to get close to a target rate without the strong degradation introduced by the generate strategy as it usually leads to a similar number of sensor events per actually generated data points. The downside is that the data point rate may be quite different on different devices if the target rate is in the range of typical sensor rates.

Now, the default behavior in phyphox is "auto", which means that it starts with "request" and switches to "generate" if the system delivers a rate that is 10% faster than the target rate.

You can pick a specific strategy by setting an additional attribute like this:

<sensor type="accelerometer" rate="0" rateStrategy="limit">

However, as described above, if the system does not give a matching rate, I would advice against using "generate" to get the exact target rate, because this will artificially duplicate or drop and re-arrange datapoint, which can be quite degregading if you then feed it to a Fourier transform. 

I am not sure why the 50 Hz case sometimes starts slower. It might be that iOS treats 50 Hz as a sign that it is a lower priority use case and allows that the sensor starts a bit later, so that the increasing rate is just a statistical effect because of the pause at the start?

Your 80 Hz example is not that surprising: The iPhone very likely does not offer a 80 Hz rate, but will still send data at 100 Hz. Phyphox recognizes that it is 20% too fast and switches to the limit strategy. In this case, every second data point is dropped because it arrives before 1/80Hz and you end up with every second data point, resulting in 50 Hz.

As long as the iPhone does not offer a native rate of 80 Hz, going with 50 Hz is you best option, because every other strategy will just artificially mess with the timing of the original data. You can also set the "stride" parameter to specifically only pick every n-th data point, but that might not be a good idea if you want to use this on different phones as well as some Android phone deliver up to 500 Hz and you end up with very different rates.

(See https://phyphox.org/wiki/index.php/Phyph...le:_sensor for the full documentation)
Reply
#3
Thank you for your very detailed explanation, as well as a very prompt reply to my private email!
I really appreciate it :>
Reply
#4
Sebastian, thank you for your recommendations on the ways to limit/ change the sampling rate.
I am going for the 'stride' thing.

I was able to install the experiment onto my 2 iPhones (12 and 18).
When it comes to a phone from Sony, a notification comes with 'unable to interpret the file version of this experiment'.

However, all the phones are on the same level Phyphox (version: 1.2.0, file format: 1.19).
The only difference is the build (iPhone: 17272, Xperia: 1020009). Could this be the reason?
Reply
#5
No, the build number is not the problem. It will always be different because the Android and iOS version of phyphox are (almost) entirely different code bases and on iOS it automatically increments with each build while on Android we have decided on a manual approach, following the official version number with patch increments for public test builds.

Normally, phyphox should only compare the file format versions... Can you share your experiment configuration, so I can try it?
Reply
#6
Thanks for your replying.
You can get the experiment from the link below.
https://drive.google.com/file/d/16rv3sob...drive_link
Reply
#7
(06-18-2026, 07:43 AM)Sebastian Staacks Wrote: No, the build number is not the problem. It will always be different because the Android and iOS version of phyphox are (almost) entirely different code bases and on iOS it automatically increments with each build while on Android we have decided on a manual approach, following the official version number with patch increments for public test builds.

Normally, phyphox should only compare the file format versions... Can you share your experiment configuration, so I can try it?

Hi Sebastian,

I hope you are still doing well.
Sorry for bothering you while you are busy ~

Have you been able to download my experiment?
Reply
#8
Sorry, for some reason I did not get a notification of your reply. (I suspect this happens when the answer is so fast that the forum still considers me to be online. I have to check this - it is not the first time this happened.)

In any case, the answer is simple:
There is a difference between the phyphox version and the file format version. The reasoning is that there can be updates and bugfix releases for the app that might not change anything about the file format. In practice we try to avoid tiny updates, so almost every new phyphox version also increases the file format version, but nevertheless you need to define that one instead of the version of the app.

You can see the phyphox versions and the corresponding file format versions here: https://phyphox.org/wiki/index.php/Version_history

So, simply define version="1.19" instead of version="1.2.0" and it should be fine. (At least I hope so - I did not have a chance to test your file specifically.)
Reply
#9
Hi Sebastian,

Thank you so much for your support, and sorry for my late reply.
The problem has been solved!

Best regards.
Reply


Forum Jump: