Quantile Arduino

Hi everybody,

I would like to know how to find the last quantile (3/4) of an array.

#include "Statistics.h" 

int sensePin = 7;

int thresHoldfinder() // new function 
{
  Statistics stats(200); //new array in statistics.h

    for (int k=0; k=199; k++) //200 values
    {
    int val = analogRead(sensePin) ; //reading the value of pin number 7
    stats.addData(val); //adding the data 
    delay(10); 
    }
    
    Serial.println(stats.mean()); //mean to quantile

}

I would like to change mean into 3rd quartile. But not sure of translation in english... and not sure if there is any library on it.

Thanks a lot !

Given a series of data points, what is the formula to obtain the third quartile ?
If you know that then do you really need a library to do it for you or could you write your own function ?

Chuoby:
I would like to know how to find the last quantile (3/4) of an array.

#include "Statistics.h"

If you want to know about the usage of a third-party library: Read the manual!

If there is no manual for the third-party library, but you have the source code: Read the source code!

And in case you find that the library has no such function which you need: Think about whether it is really a good idea to use that library!

Hi jurs,

Of course this library isn't the good one... and of course i've already read the manual. It was just an example to expose what i wanted.

To UKHeliBob, don't think that is so easy to find the 3rd quartile of an array. You first have to sort it and then find the element number 75 (if it's a 100 elements arrays)

So i'll find a way to sort an array. Ideas ?

So i'll find a way to sort an array. Ideas ?

Start with a bubble sort. Slow but easy. Put the sort in a function then when you improve it (plenty of advice on the Web) then you can drop in a replacement function.

Chuoby: So i'll find a way to sort an array. Ideas ?

You can either use one of the sorting algorithms and write a sorting function of your own.

But the AVR LIBC has also a "qsort()" function (Quicksort algorithm) you can use with Arduino arrays: http://www.nongnu.org/avr-libc/user-manual/group__avr__stdlib.html#gafd4bf2faec43342e7ad3d2ab37bac1fe (unfortunately not very self-explaining)

Which library do you use? Did you check that your library has no sorting function built-in? Can you access (read and write) single values by index in the "stats" object by using functions for that or access the stats-array directly?