Constructing errors in a logarithmic domain with negative values ​​(Matlab)

I have a vector, name it x, which contains very small numbers, which I calculated from the average. I would like to build a logarithmic transformation of x, for example, y = 10 * log10 (x), as well as errors equal to + - 2 standard deviations calculated when searching for the average value.

For this, I use the following code:

figure
errorbar(lengths, 10*log10(x), ...
    10*log10(x-2*std_x), 10*log10(x+2*std_x), 'o')

My problem is that since x contains such small values, x-2 * std_x is usually a negative number, and you cannot take a log of negative numbers.

So, I suppose my question is, how can I construct errors in the logarithmic domain when subtracting the standard deviation in the linear domain gives me negative numbers? I can not do + -

+3
source share
3 answers

You can replace these values ​​with a small value, but with the ability to log into the system (say, 40 dB lower):

minb = x-2*std_x;
mask = (minb <= 0);
minb(mask) = x/1e4;
... use 10*log10(minb) instead

Or just a threshold to some minimum:

K = min(x) / 1e4; % so that K is 40 db below the smallest x
... use 10*log10(max(K, x-2*std_x)) instead.

Or similar things.

EDIT to summarize comments and further thoughts:

, , . / (, x% , ). , , , . , , , +/- K * std_deviation, .

cdf F (x), "" (.. ), , ,

F '(x1) = F' (x2), F (x2) - F (x1) = , x1 <= mode <= x2.

+/- K std_deviation , , , , , .

+1

errorbar .

figure
errorbar(lengths, 10*log10(x),10*log10(2*std_x), 'o')

std_x , errorbar, 10*log10(x-2*std_x) 10*log10(x+2*std_x)

+2

use the error bar in two error configurations, then change the y axis to logarithmic:

eps = 1E-4;  %whatever you consider to be a very small fraction
ebl = min(2*std_x, x*(1-eps));
ebu = 2*std_x;
errorbar(lengths, x, ebl, ebu, 'o');
set(gca, 'YScale', 'log');

you can adjust yaxis range manually using ylim

+2
source

Source: https://habr.com/ru/post/1779306/


All Articles