Hi all
I am having difficulty understanding the output of [array quantile]. From the help-file it seems it expects an input between 0 and 1, and also the values in the array should be in that range. The output seems to be in the range between 0 and <array-size> - 1. But what does it mean?
Can I use this somehow to achieve this:
I have n samples and input q while 0 < q < 1. I would like to know the value x for which q*100 percent samples are smaller than x and (1- q)*100 percent bigger.
Thanks, Roman
There is a bug in the help of [array] in that 'array-help-3' and 'array-help-4' are multiply defined. So, for the quantile example to work, you may want to delete the the array named 'array-help-3' in the [pd define] subpatch.
I'll send a fixed version to github.
On Sun, 2019-10-27 at 14:46 +0100, Roman Haefeli wrote:
Hi all
I am having difficulty understanding the output of [array quantile]. From the help-file it seems it expects an input between 0 and 1, and also the values in the array should be in that range. The output seems to be in the range between 0 and <array-size> - 1. But what does it mean?
Can I use this somehow to achieve this:
I have n samples and input q while 0 < q < 1. I would like to know the value x for which q*100 percent samples are smaller than x and (1- q)*100 percent bigger.
Thanks, Roman
While still not understanding the purpose of [array quantile], I was able to achieve this:
I have n samples and input q while 0 < q < 1. I would like to know the value x for which q*100 percent samples are smaller than x and (1- q)*100 percent bigger.
Since [text define] got a 'sort'ing feature recently, I am using it to sort the array. Thus, I migrate the data from [array] to [text], sort it, transfer it back to the [array]. Once sorted, it is easy to get the median or any n-quantile.
I noticed, that [text set] has a time complexity of O(n²), so for efficiently copying data around, I went [array get] -> [list store] -> [text fromlist] which has linear time complexity.
I see that [text set] is versatile and thus comes with a cost, but wouldn't it be nice to still have a way to append to the existing text with linear time complexity? I've been using [text] a few times and realize only now that because of this it is only feasible up to a certain number of lines, since adding lines is getting costlier the larger the stored text. Only when the whole text can be loaded at once (which is not always the case), the [list store] work-around can be used.
I wonder whether a dedicated [text append] could help here, that lacks the functionality of [text set], but would be fast. Or is it the data structure used by [text] itself that makes it impossible to append in linear time?
Roman
I wonder whether a dedicated [text append] could help here, that lacks the functionality of [text set], but would be fast.
that would be a leaky abstraction. I think the [text set] / [text get] methods can be improved to get O(N) complexity. I think we only need to cache the line positions.
Christof
Gesendet: Montag, 28. Oktober 2019 um 09:39 Uhr Von: "Roman Haefeli" reduzent@gmail.com An: Pd-List pd-list@lists.iem.at Betreff: [PD] fast way to append to [text] (was: [array quantile] explanation)
While still not understanding the purpose of [array quantile], I was able to achieve this:
I have n samples and input q while 0 < q < 1. I would like to know the value x for which q*100 percent samples are smaller than x and (1- q)*100 percent bigger.
Since [text define] got a 'sort'ing feature recently, I am using it to sort the array. Thus, I migrate the data from [array] to [text], sort it, transfer it back to the [array]. Once sorted, it is easy to get the median or any n-quantile.
I noticed, that [text set] has a time complexity of O(n²), so for efficiently copying data around, I went [array get] -> [list store] -> [text fromlist] which has linear time complexity.
I see that [text set] is versatile and thus comes with a cost, but wouldn't it be nice to still have a way to append to the existing text with linear time complexity? I've been using [text] a few times and realize only now that because of this it is only feasible up to a certain number of lines, since adding lines is getting costlier the larger the stored text. Only when the whole text can be loaded at once (which is not always the case), the [list store] work-around can be used.
I wonder whether a dedicated [text append] could help here, that lacks the functionality of [text set], but would be fast. Or is it the data structure used by [text] itself that makes it impossible to append in linear time?
Roman _______________________________________________ Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
Yes but not with perfect accuracy. You have to make a histogram of the samples (choosing some bin size; that's what limits accuracy) and then array qualtile will do exactly what you're looking for.
I use it for instance to do automatic level setting. I ask for the 90% quamtile of env~ output (in dB) over a period of 10 seconds or so.
cheers Miller
On Sun, Oct 27, 2019 at 02:46:29PM +0100, Roman Haefeli wrote:
Hi all
I am having difficulty understanding the output of [array quantile]. From the help-file it seems it expects an input between 0 and 1, and also the values in the array should be in that range. The output seems to be in the range between 0 and <array-size> - 1. But what does it mean?
Can I use this somehow to achieve this:
I have n samples and input q while 0 < q < 1. I would like to know the value x for which q*100 percent samples are smaller than x and (1- q)*100 percent bigger.
Thanks, Roman
Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
On Mon, 2019-10-28 at 13:50 -0700, Miller Puckette wrote:
Yes
Cool.
but not with perfect accuracy.
I don't mind.
You have to make a histogram of the samples (choosing some bin size;
Forgive my ignorance, but how can I create a histogram out of an unordered set of samples? Do I just iterate over all samples "manually" and count up the bin depending on in which bin it falls?
that's what limits accuracy) and then array qualtile will do exactly what you're looking for.
So [array quantile] is meant to be used on a histogram of the raw data, as opposed to the raw data directly? That's why it returns something that looks like an index, namely the index of the bin of your histogram?
I use it for instance to do automatic level setting. I ask for the 90% quamtile of env~ output (in dB) over a period of 10 seconds or so.
Thanks, this I understand and is very similar to the stuff I'm interested in.
Roman
On Sun, Oct 27, 2019 at 02:46:29PM +0100, Roman Haefeli wrote:
Hi all
I am having difficulty understanding the output of [array quantile]. From the help-file it seems it expects an input between 0 and 1, and also the values in the array should be in that range. The output seems to be in the range between 0 and <array-size> - 1. But what does it mean?
Can I use this somehow to achieve this:
I have n samples and input q while 0 < q < 1. I would like to know the value x for which q*100 percent samples are smaller than x and (1- q)*100 percent bigger.
Thanks, Roman
Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
Yep, all your surmises are right.
cheers M
On Mon, Oct 28, 2019 at 10:24:58PM +0100, Roman Haefeli wrote:
On Mon, 2019-10-28 at 13:50 -0700, Miller Puckette wrote:
Yes
Cool.
but not with perfect accuracy.
I don't mind.
You have to make a histogram of the samples (choosing some bin size;
Forgive my ignorance, but how can I create a histogram out of an unordered set of samples? Do I just iterate over all samples "manually" and count up the bin depending on in which bin it falls?
that's what limits accuracy) and then array qualtile will do exactly what you're looking for.
So [array quantile] is meant to be used on a histogram of the raw data, as opposed to the raw data directly? That's why it returns something that looks like an index, namely the index of the bin of your histogram?
I use it for instance to do automatic level setting. I ask for the 90% quamtile of env~ output (in dB) over a period of 10 seconds or so.
Thanks, this I understand and is very similar to the stuff I'm interested in.
Roman
On Sun, Oct 27, 2019 at 02:46:29PM +0100, Roman Haefeli wrote:
Hi all
I am having difficulty understanding the output of [array quantile]. From the help-file it seems it expects an input between 0 and 1, and also the values in the array should be in that range. The output seems to be in the range between 0 and <array-size> - 1. But what does it mean?
Can I use this somehow to achieve this:
I have n samples and input q while 0 < q < 1. I would like to know the value x for which q*100 percent samples are smaller than x and (1- q)*100 percent bigger.
Thanks, Roman
Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list