nespinoza / juliet

A versatile modelling tool for transiting and non-transiting (single and multiple) exoplanetary systems
MIT License
55 stars 30 forks source link

bin_data when errors are provided - problem in error formula? #117

Closed melissa-hobson closed 5 months ago

melissa-hobson commented 7 months ago

I think there may be an error in the computation of the binned errors when errors are provided. The current formula is:

            y_err_bins.append(
                np.sqrt( np.sum( yerr[i: i + n_bin - 1]**2 ) / len( yerr[i: i + n_bin - 1] )  )
                            ) 

But, let's say we're using the mean because then the error propagation is straightforward. The mean is the sum of the points, divided by the number of points (which is an integer, with no error). Then by error propagation, the error of the sum is the square root of the sum of the errors squared; and we divide by the number of points to get the error of the mean. So, essentially, I think in the formula above, the square root is wrapping the number of points when it shouldn't, and the formula should be:

            y_err_bins.append(
                np.sqrt( np.sum( yerr[i: i + n_bin - 1]**2 ) ) / len( yerr[i: i + n_bin - 1] )  
                            ) 

(I admit I'm not sure about the median...)

nespinoza commented 5 months ago

Hi @melissa-hobson,

You are correct! This must have been a typo. Fixing on the next juliet version.

N.

nespinoza commented 5 months ago

Fixed on latest version (2.2.6).

N.