Re: [R] Empirical density estimation

2018-03-11 Thread Jeff Newmiller

cwhmisc package provides essentially the algorithm outlined by Dan.

If you want answers outside your original data (extrapolation) then the 
following code at least won't give broken answers, though it is not 
necessarily any more "correct" for extrapolation than the approx solution 
is.


Regarding "needing this for reporting", do thoroughly read ?density as 
Bert suggested, because the bandwidth parameter affects your answers and 
there are various historical recommendations for choosing possible 
bandwidth values, and really no "right" answer.



smoothed.df2 <- function ( d ) {
F <- cumsum( d$y )
F <- F / F[ length( F ) ] * ( length( F ) - 0.5 ) / length( F )
eF <- splinefun( d$x, qlogis( F ), "monoH.FC" )
function( x ) {
efx <- eF( x )
plogis( efx )
}
}

set.seed( 42 )
Dat <- c( rnorm( 100, 1 ), rnorm( 100, 5 ) )

d <- density( Dat )

CDF1 <- cwhmisc::smoothed.df( d )
plot( Dat, CDF1( Dat ) )

CDF2 <- smoothed.df2( d )
plot( Dat, CDF2( Dat ) )

CDF1( -5 ) # <0
CDF2( -5 ) # >0


On Sun, 11 Mar 2018, Daniel Nordlund wrote:


On 3/11/2018 3:35 PM, Christofer Bogaso wrote:

But for my reporting purpose, I need to generate a bell curve like
plot based on empirical PDF, that also contains original points.

Any idea would be helpful. Thanks,




Christofer,

something like the following may get you what you want:

## get the kernel density estimate
dens <- density(Dat)

## estimate the density at your original points
dnew <- approx(dens$x,dens$y,xout=Dat)

## plot kernel density estimate
plot(dx)

## add your original values with the estimated density
points(dnew, pch=1, cex=0.5, col="red")


Hope this is helpful,

Dan

--
Daniel Nordlund
Port Townsend, WA  USA

On Mon, Mar 12, 2018 at 3:49 AM, Bert Gunter  
wrote:
You need to re-read ?density and perhaps think again -- or do some study 
--

about how a (kernel) density estimate works. The points at which the
estimate is calculated are *not* the values given, nor should they be!

Cheers,
Bert



Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Sun, Mar 11, 2018 at 11:45 AM, Christofer Bogaso
 wrote:


Hi,

Let say I have below vector of data-points :

Dat = c(-0.444, -0.25, -0.237449799196787, 
-0.227467046669042,


-0.227454464682363, -0.22, -0.214876033057851, -0.211781206171108,

-0.199891067538126, -0.192920353982301, -0.192307692307692,
-0.186046511627907,

-0.184418145956608, -0.181818181818182, -0.181818181818182,
-0.181266261925412,

-0.181003118503119, -0.179064587973274, -0.178217821782178,
-0.17809021675454,

-0.177685950413223, -0.177570093457944, -0.176470588235294,
-0.176470588235294,

-0.174825741611282, -0.168021680216802, -0.167,
-0.167,

-0.166380789022298, -0.164209115281501, -0.164011246485473,
-0.162689804772234,

-0.162361623616236, -0.160161507402423, -0.16, -0.155038759689922,

-0.154172560113154, -0.15311004784689, -0.151515151515152,
-0.151462994836489,

-0.151098901098901, -0.150537634408602, -0.150442477876106,
-0.150406504065041,

-0.149904214559387, -0.149882903981265, -0.149797570850202,
-0.148496240601504,

-0.148325358851675, -0.147540983606557, -0.147239263803681,
-0.146989966555184,

-0.14622641509434, -0.146095717884131, -0.145994832041344,
-0.14572864321608,

-0.145161290322581, -0.144292237442922, -0.144144144144144,
-0.144021739130435,

-0.14375, -0.142212189616253, -0.141122913505311, -0.140324963072378,

-0.139344262295082, -0.13884007029877, -0.138356164383562,
-0.137626262626263,

-0.137142857142857, -0.136690647482014, -0.136577708006279,
-0.136363636363636,

-0.136094674556213, -0.135879774577332, -0.135586319218241,
-0.135135135135135,

-0.132780082987552, -0.132209405501331, -0.132023755139333,
-0.131233595800525,

-0.130434782608696, -0.130434782608696, -0.130268199233717,
-0.128813559322034,

-0.1284046692607, -0.128205128205128, -0.128182616330114,
-0.127937336814621,

-0.126283367556468, -0.125853658536585, -0.125448028673835,
-0.125425564840607,

-0.125311203319502, -0.125, -0.124401913875598, -0.124248496993988,

-0.124031007751938, -0.123572170301142, -0.123188405797102,
-0.122905027932961,

-0.1216667, -0.121573685907772, -0.120658135283364,
-0.120540019286403,

-0.119858156028369, -0.11965811965812, -0.11965811965812,
-0.119565217391304,

-0.118942731277533, -0.117820324005891, -0.116257947320618,
-0.115789473684211,

-0.115683584819387, -0.115384615384615, -0.115281501340483,
-0.114492753623188,

-0.114357262103506, -0.114285714285714, -0.114035087719298,
-0.113181972212809,

-0.112790697674419, -0.112781954887218, -0.112195121951219,
-0.112191473448018,

-0.111, -0.111, -0.110813226094727,
-0.110384300899428,

-0.110147441457069, -0.110137672090113, -0.109913793103448,

Re: [R] Empirical density estimation

2018-03-11 Thread Daniel Nordlund

On 3/11/2018 3:35 PM, Christofer Bogaso wrote:

But for my reporting purpose, I need to generate a bell curve like
plot based on empirical PDF, that also contains original points.

Any idea would be helpful. Thanks,




Christofer,

something like the following may get you what you want:

## get the kernel density estimate
dens <- density(Dat)

## estimate the density at your original points
dnew <- approx(dens$x,dens$y,xout=Dat)

## plot kernel density estimate
plot(dx)

## add your original values with the estimated density
points(dnew, pch=1, cex=0.5, col="red")


Hope this is helpful,

Dan

--
Daniel Nordlund
Port Townsend, WA  USA


On Mon, Mar 12, 2018 at 3:49 AM, Bert Gunter  wrote:

You need to re-read ?density and perhaps think again -- or do some study --
about how a (kernel) density estimate works. The points at which the
estimate is calculated are *not* the values given, nor should they be!

Cheers,
Bert



Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Sun, Mar 11, 2018 at 11:45 AM, Christofer Bogaso
 wrote:


Hi,

Let say I have below vector of data-points :

Dat = c(-0.444, -0.25, -0.237449799196787, -0.227467046669042,

-0.227454464682363, -0.22, -0.214876033057851, -0.211781206171108,

-0.199891067538126, -0.192920353982301, -0.192307692307692,
-0.186046511627907,

-0.184418145956608, -0.181818181818182, -0.181818181818182,
-0.181266261925412,

-0.181003118503119, -0.179064587973274, -0.178217821782178,
-0.17809021675454,

-0.177685950413223, -0.177570093457944, -0.176470588235294,
-0.176470588235294,

-0.174825741611282, -0.168021680216802, -0.167,
-0.167,

-0.166380789022298, -0.164209115281501, -0.164011246485473,
-0.162689804772234,

-0.162361623616236, -0.160161507402423, -0.16, -0.155038759689922,

-0.154172560113154, -0.15311004784689, -0.151515151515152,
-0.151462994836489,

-0.151098901098901, -0.150537634408602, -0.150442477876106,
-0.150406504065041,

-0.149904214559387, -0.149882903981265, -0.149797570850202,
-0.148496240601504,

-0.148325358851675, -0.147540983606557, -0.147239263803681,
-0.146989966555184,

-0.14622641509434, -0.146095717884131, -0.145994832041344,
-0.14572864321608,

-0.145161290322581, -0.144292237442922, -0.144144144144144,
-0.144021739130435,

-0.14375, -0.142212189616253, -0.141122913505311, -0.140324963072378,

-0.139344262295082, -0.13884007029877, -0.138356164383562,
-0.137626262626263,

-0.137142857142857, -0.136690647482014, -0.136577708006279,
-0.136363636363636,

-0.136094674556213, -0.135879774577332, -0.135586319218241,
-0.135135135135135,

-0.132780082987552, -0.132209405501331, -0.132023755139333,
-0.131233595800525,

-0.130434782608696, -0.130434782608696, -0.130268199233717,
-0.128813559322034,

-0.1284046692607, -0.128205128205128, -0.128182616330114,
-0.127937336814621,

-0.126283367556468, -0.125853658536585, -0.125448028673835,
-0.125425564840607,

-0.125311203319502, -0.125, -0.124401913875598, -0.124248496993988,

-0.124031007751938, -0.123572170301142, -0.123188405797102,
-0.122905027932961,

-0.1216667, -0.121573685907772, -0.120658135283364,
-0.120540019286403,

-0.119858156028369, -0.11965811965812, -0.11965811965812,
-0.119565217391304,

-0.118942731277533, -0.117820324005891, -0.116257947320618,
-0.115789473684211,

-0.115683584819387, -0.115384615384615, -0.115281501340483,
-0.114492753623188,

-0.114357262103506, -0.114285714285714, -0.114035087719298,
-0.113181972212809,

-0.112790697674419, -0.112781954887218, -0.112195121951219,
-0.112191473448018,

-0.111, -0.111, -0.110813226094727,
-0.110384300899428,

-0.110147441457069, -0.110137672090113, -0.109913793103448,
-0.109792284866469,

-0.109375, -0.10919540229885, -0.109112709832134, -0.10844250363901,

-0.107776617954071, -0.10752688172043, -0.107317073170732,
-0.106674272675414,

-0.106382978723404, -0.106100795755968, -0.106060606060606,
-0.10595160235448,

-0.105742474070326, -0.105263157894737, -0.104454685099846,
-0.104283054003724,

-0.103916449086162, -0.103723404255319, -0.103448275862069,
-0.102737680438029,

-0.10267471958585, -0.101696871753434, -0.100893997445721,
-0.10041265474553,

-0.100042983021706, -0.1, -0.0995111731843576, -0.099502487562189,

-0.0994117647058824, -0.0991561181434598, -0.0989492119089317,

-0.0988372093023255, -0.0983908045977012, -0.0983050847457627,

-0.0977198697068404, -0.0974702380952382, -0.0973819695475956,

-0.097345132743363, -0.0971472629144179, -0.0971438645980254,

-0.0961538461538461, -0.096062667491239, -0.0957347238935687,

-0.0956521739130435, -0.0954773869346733, -0.0954115076474873,

-0.0952380952380952, -0.0951115834218915, -0.0950642007303569,

-0.0949423247559894, -0.0947368421052631, -0.0946291560102303,

-0.0945220193340494, -0.0944309927360775, 

Re: [R] Empirical density estimation

2018-03-11 Thread Christofer Bogaso
But for my reporting purpose, I need to generate a bell curve like
plot based on empirical PDF, that also contains original points.

Any idea would be helpful. Thanks,

On Mon, Mar 12, 2018 at 3:49 AM, Bert Gunter  wrote:
> You need to re-read ?density and perhaps think again -- or do some study --
> about how a (kernel) density estimate works. The points at which the
> estimate is calculated are *not* the values given, nor should they be!
>
> Cheers,
> Bert
>
>
>
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming along and
> sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
> On Sun, Mar 11, 2018 at 11:45 AM, Christofer Bogaso
>  wrote:
>>
>> Hi,
>>
>> Let say I have below vector of data-points :
>>
>> Dat = c(-0.444, -0.25, -0.237449799196787, -0.227467046669042,
>>
>> -0.227454464682363, -0.22, -0.214876033057851, -0.211781206171108,
>>
>> -0.199891067538126, -0.192920353982301, -0.192307692307692,
>> -0.186046511627907,
>>
>> -0.184418145956608, -0.181818181818182, -0.181818181818182,
>> -0.181266261925412,
>>
>> -0.181003118503119, -0.179064587973274, -0.178217821782178,
>> -0.17809021675454,
>>
>> -0.177685950413223, -0.177570093457944, -0.176470588235294,
>> -0.176470588235294,
>>
>> -0.174825741611282, -0.168021680216802, -0.167,
>> -0.167,
>>
>> -0.166380789022298, -0.164209115281501, -0.164011246485473,
>> -0.162689804772234,
>>
>> -0.162361623616236, -0.160161507402423, -0.16, -0.155038759689922,
>>
>> -0.154172560113154, -0.15311004784689, -0.151515151515152,
>> -0.151462994836489,
>>
>> -0.151098901098901, -0.150537634408602, -0.150442477876106,
>> -0.150406504065041,
>>
>> -0.149904214559387, -0.149882903981265, -0.149797570850202,
>> -0.148496240601504,
>>
>> -0.148325358851675, -0.147540983606557, -0.147239263803681,
>> -0.146989966555184,
>>
>> -0.14622641509434, -0.146095717884131, -0.145994832041344,
>> -0.14572864321608,
>>
>> -0.145161290322581, -0.144292237442922, -0.144144144144144,
>> -0.144021739130435,
>>
>> -0.14375, -0.142212189616253, -0.141122913505311, -0.140324963072378,
>>
>> -0.139344262295082, -0.13884007029877, -0.138356164383562,
>> -0.137626262626263,
>>
>> -0.137142857142857, -0.136690647482014, -0.136577708006279,
>> -0.136363636363636,
>>
>> -0.136094674556213, -0.135879774577332, -0.135586319218241,
>> -0.135135135135135,
>>
>> -0.132780082987552, -0.132209405501331, -0.132023755139333,
>> -0.131233595800525,
>>
>> -0.130434782608696, -0.130434782608696, -0.130268199233717,
>> -0.128813559322034,
>>
>> -0.1284046692607, -0.128205128205128, -0.128182616330114,
>> -0.127937336814621,
>>
>> -0.126283367556468, -0.125853658536585, -0.125448028673835,
>> -0.125425564840607,
>>
>> -0.125311203319502, -0.125, -0.124401913875598, -0.124248496993988,
>>
>> -0.124031007751938, -0.123572170301142, -0.123188405797102,
>> -0.122905027932961,
>>
>> -0.1216667, -0.121573685907772, -0.120658135283364,
>> -0.120540019286403,
>>
>> -0.119858156028369, -0.11965811965812, -0.11965811965812,
>> -0.119565217391304,
>>
>> -0.118942731277533, -0.117820324005891, -0.116257947320618,
>> -0.115789473684211,
>>
>> -0.115683584819387, -0.115384615384615, -0.115281501340483,
>> -0.114492753623188,
>>
>> -0.114357262103506, -0.114285714285714, -0.114035087719298,
>> -0.113181972212809,
>>
>> -0.112790697674419, -0.112781954887218, -0.112195121951219,
>> -0.112191473448018,
>>
>> -0.111, -0.111, -0.110813226094727,
>> -0.110384300899428,
>>
>> -0.110147441457069, -0.110137672090113, -0.109913793103448,
>> -0.109792284866469,
>>
>> -0.109375, -0.10919540229885, -0.109112709832134, -0.10844250363901,
>>
>> -0.107776617954071, -0.10752688172043, -0.107317073170732,
>> -0.106674272675414,
>>
>> -0.106382978723404, -0.106100795755968, -0.106060606060606,
>> -0.10595160235448,
>>
>> -0.105742474070326, -0.105263157894737, -0.104454685099846,
>> -0.104283054003724,
>>
>> -0.103916449086162, -0.103723404255319, -0.103448275862069,
>> -0.102737680438029,
>>
>> -0.10267471958585, -0.101696871753434, -0.100893997445721,
>> -0.10041265474553,
>>
>> -0.100042983021706, -0.1, -0.0995111731843576, -0.099502487562189,
>>
>> -0.0994117647058824, -0.0991561181434598, -0.0989492119089317,
>>
>> -0.0988372093023255, -0.0983908045977012, -0.0983050847457627,
>>
>> -0.0977198697068404, -0.0974702380952382, -0.0973819695475956,
>>
>> -0.097345132743363, -0.0971472629144179, -0.0971438645980254,
>>
>> -0.0961538461538461, -0.096062667491239, -0.0957347238935687,
>>
>> -0.0956521739130435, -0.0954773869346733, -0.0954115076474873,
>>
>> -0.0952380952380952, -0.0951115834218915, -0.0950642007303569,
>>
>> -0.0949423247559894, -0.0947368421052631, -0.0946291560102303,
>>
>> -0.0945220193340494, -0.0944309927360775, -0.0943016759776536,
>>
>> -0.0942720763723149, -0.0941770647653002, -0.0940298507462686,
>>
>> 

Re: [R] Empirical density estimation

2018-03-11 Thread Jim Lemon
Hi Christofer,
You may be looking for ecdf (stats) for a start, then working out a
way to translate the cumulative density values into probability
values.

Jim


On Mon, Mar 12, 2018 at 5:45 AM, Christofer Bogaso
 wrote:
> Hi,
>
> Let say I have below vector of data-points :
>
> Dat = c(-0.444, -0.25, -0.237449799196787, -0.227467046669042,
>
> -0.227454464682363, -0.22, -0.214876033057851, -0.211781206171108,
>
> -0.199891067538126, -0.192920353982301, -0.192307692307692, 
> -0.186046511627907,
>
> -0.184418145956608, -0.181818181818182, -0.181818181818182, 
> -0.181266261925412,
>
> -0.181003118503119, -0.179064587973274, -0.178217821782178, -0.17809021675454,
>
> -0.177685950413223, -0.177570093457944, -0.176470588235294, 
> -0.176470588235294,
>
> -0.174825741611282, -0.168021680216802, -0.167, 
> -0.167,
>
> -0.166380789022298, -0.164209115281501, -0.164011246485473, 
> -0.162689804772234,
>
> -0.162361623616236, -0.160161507402423, -0.16, -0.155038759689922,
>
> -0.154172560113154, -0.15311004784689, -0.151515151515152, -0.151462994836489,
>
> -0.151098901098901, -0.150537634408602, -0.150442477876106, 
> -0.150406504065041,
>
> -0.149904214559387, -0.149882903981265, -0.149797570850202, 
> -0.148496240601504,
>
> -0.148325358851675, -0.147540983606557, -0.147239263803681, 
> -0.146989966555184,
>
> -0.14622641509434, -0.146095717884131, -0.145994832041344, -0.14572864321608,
>
> -0.145161290322581, -0.144292237442922, -0.144144144144144, 
> -0.144021739130435,
>
> -0.14375, -0.142212189616253, -0.141122913505311, -0.140324963072378,
>
> -0.139344262295082, -0.13884007029877, -0.138356164383562, -0.137626262626263,
>
> -0.137142857142857, -0.136690647482014, -0.136577708006279, 
> -0.136363636363636,
>
> -0.136094674556213, -0.135879774577332, -0.135586319218241, 
> -0.135135135135135,
>
> -0.132780082987552, -0.132209405501331, -0.132023755139333, 
> -0.131233595800525,
>
> -0.130434782608696, -0.130434782608696, -0.130268199233717, 
> -0.128813559322034,
>
> -0.1284046692607, -0.128205128205128, -0.128182616330114, -0.127937336814621,
>
> -0.126283367556468, -0.125853658536585, -0.125448028673835, 
> -0.125425564840607,
>
> -0.125311203319502, -0.125, -0.124401913875598, -0.124248496993988,
>
> -0.124031007751938, -0.123572170301142, -0.123188405797102, 
> -0.122905027932961,
>
> -0.1216667, -0.121573685907772, -0.120658135283364, 
> -0.120540019286403,
>
> -0.119858156028369, -0.11965811965812, -0.11965811965812, -0.119565217391304,
>
> -0.118942731277533, -0.117820324005891, -0.116257947320618, 
> -0.115789473684211,
>
> -0.115683584819387, -0.115384615384615, -0.115281501340483, 
> -0.114492753623188,
>
> -0.114357262103506, -0.114285714285714, -0.114035087719298, 
> -0.113181972212809,
>
> -0.112790697674419, -0.112781954887218, -0.112195121951219, 
> -0.112191473448018,
>
> -0.111, -0.111, -0.110813226094727, 
> -0.110384300899428,
>
> -0.110147441457069, -0.110137672090113, -0.109913793103448, 
> -0.109792284866469,
>
> -0.109375, -0.10919540229885, -0.109112709832134, -0.10844250363901,
>
> -0.107776617954071, -0.10752688172043, -0.107317073170732, -0.106674272675414,
>
> -0.106382978723404, -0.106100795755968, -0.106060606060606, -0.10595160235448,
>
> -0.105742474070326, -0.105263157894737, -0.104454685099846, 
> -0.104283054003724,
>
> -0.103916449086162, -0.103723404255319, -0.103448275862069, 
> -0.102737680438029,
>
> -0.10267471958585, -0.101696871753434, -0.100893997445721, -0.10041265474553,
>
> -0.100042983021706, -0.1, -0.0995111731843576, -0.099502487562189,
>
> -0.0994117647058824, -0.0991561181434598, -0.0989492119089317,
>
> -0.0988372093023255, -0.0983908045977012, -0.0983050847457627,
>
> -0.0977198697068404, -0.0974702380952382, -0.0973819695475956,
>
> -0.097345132743363, -0.0971472629144179, -0.0971438645980254,
>
> -0.0961538461538461, -0.096062667491239, -0.0957347238935687,
>
> -0.0956521739130435, -0.0954773869346733, -0.0954115076474873,
>
> -0.0952380952380952, -0.0951115834218915, -0.0950642007303569,
>
> -0.0949423247559894, -0.0947368421052631, -0.0946291560102303,
>
> -0.0945220193340494, -0.0944309927360775, -0.0943016759776536,
>
> -0.0942720763723149, -0.0941770647653002, -0.0940298507462686,
>
> -0.094017094017094, -0.0935672514619884, -0.0934579439252337,
>
> -0.0930232558139535, -0.0929772502472798, -0.0929054054054054,
>
> -0.0928778745255637, -0.0927700348432055, -0.0925266903914591,
>
> -0.0922502666192677, -0.0918094218415418, -0.0915254237288135,
>
> -0.0914774596906876, -0.0914662894860915, -0.0914285714285715,
>
> -0.0912322274881517, -0.090909090909091, -0.0909090909090909,
>
> -0.09079754601227, -0.0907071455016661, -0.0906593406593406,
>
> -0.0903614457831325, -0.0903323548906352, -0.09, -0.0897243107769424,
>
> -0.0896358543417368, -0.0895522388059702, -0.0895052902487847,
>
> -0.0891719745222929, -0.0888, -0.0887227819304518,
>
> 

Re: [R] Empirical density estimation

2018-03-11 Thread Bert Gunter
You need to re-read ?density and perhaps think again -- or do some study --
about how a (kernel) density estimate works. The points at which the
estimate is calculated are *not* the values given, nor should they be!

Cheers,
Bert



Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Sun, Mar 11, 2018 at 11:45 AM, Christofer Bogaso <
bogaso.christo...@gmail.com> wrote:

> Hi,
>
> Let say I have below vector of data-points :
>
> Dat = c(-0.444, -0.25, -0.237449799196787, -0.227467046669042,
>
> -0.227454464682363, -0.22, -0.214876033057851, -0.211781206171108,
>
> -0.199891067538126, -0.192920353982301, -0.192307692307692,
> -0.186046511627907,
>
> -0.184418145956608, -0.181818181818182, -0.181818181818182,
> -0.181266261925412,
>
> -0.181003118503119, -0.179064587973274, -0.178217821782178,
> -0.17809021675454,
>
> -0.177685950413223, -0.177570093457944, -0.176470588235294,
> -0.176470588235294,
>
> -0.174825741611282, -0.168021680216802, -0.167,
> -0.167,
>
> -0.166380789022298, -0.164209115281501, -0.164011246485473,
> -0.162689804772234,
>
> -0.162361623616236, -0.160161507402423, -0.16, -0.155038759689922,
>
> -0.154172560113154, -0.15311004784689, -0.151515151515152,
> -0.151462994836489,
>
> -0.151098901098901, -0.150537634408602, -0.150442477876106,
> -0.150406504065041,
>
> -0.149904214559387, -0.149882903981265, -0.149797570850202,
> -0.148496240601504,
>
> -0.148325358851675, -0.147540983606557, -0.147239263803681,
> -0.146989966555184,
>
> -0.14622641509434, -0.146095717884131, -0.145994832041344,
> -0.14572864321608,
>
> -0.145161290322581, -0.144292237442922, -0.144144144144144,
> -0.144021739130435,
>
> -0.14375, -0.142212189616253, -0.141122913505311, -0.140324963072378,
>
> -0.139344262295082, -0.13884007029877, -0.138356164383562,
> -0.137626262626263,
>
> -0.137142857142857, -0.136690647482014, -0.136577708006279,
> -0.136363636363636,
>
> -0.136094674556213, -0.135879774577332, -0.135586319218241,
> -0.135135135135135,
>
> -0.132780082987552, -0.132209405501331, -0.132023755139333,
> -0.131233595800525,
>
> -0.130434782608696, -0.130434782608696, -0.130268199233717,
> -0.128813559322034,
>
> -0.1284046692607, -0.128205128205128, -0.128182616330114,
> -0.127937336814621,
>
> -0.126283367556468, -0.125853658536585, -0.125448028673835,
> -0.125425564840607,
>
> -0.125311203319502, -0.125, -0.124401913875598, -0.124248496993988,
>
> -0.124031007751938, -0.123572170301142, -0.123188405797102,
> -0.122905027932961,
>
> -0.1216667, -0.121573685907772, -0.120658135283364,
> -0.120540019286403,
>
> -0.119858156028369, -0.11965811965812, -0.11965811965812,
> -0.119565217391304,
>
> -0.118942731277533, -0.117820324005891, -0.116257947320618,
> -0.115789473684211,
>
> -0.115683584819387, -0.115384615384615, -0.115281501340483,
> -0.114492753623188,
>
> -0.114357262103506, -0.114285714285714, -0.114035087719298,
> -0.113181972212809,
>
> -0.112790697674419, -0.112781954887218, -0.112195121951219,
> -0.112191473448018,
>
> -0.111, -0.111, -0.110813226094727,
> -0.110384300899428,
>
> -0.110147441457069, -0.110137672090113, -0.109913793103448,
> -0.109792284866469,
>
> -0.109375, -0.10919540229885, -0.109112709832134, -0.10844250363901,
>
> -0.107776617954071, -0.10752688172043, -0.107317073170732,
> -0.106674272675414,
>
> -0.106382978723404, -0.106100795755968, -0.106060606060606,
> -0.10595160235448,
>
> -0.105742474070326, -0.105263157894737, -0.104454685099846,
> -0.104283054003724,
>
> -0.103916449086162, -0.103723404255319, -0.103448275862069,
> -0.102737680438029,
>
> -0.10267471958585, -0.101696871753434, -0.100893997445721,
> -0.10041265474553,
>
> -0.100042983021706, -0.1, -0.0995111731843576, -0.099502487562189,
>
> -0.0994117647058824, -0.0991561181434598, -0.0989492119089317,
>
> -0.0988372093023255, -0.0983908045977012, -0.0983050847457627,
>
> -0.0977198697068404, -0.0974702380952382, -0.0973819695475956,
>
> -0.097345132743363, -0.0971472629144179, -0.0971438645980254,
>
> -0.0961538461538461, -0.096062667491239, -0.0957347238935687,
>
> -0.0956521739130435, -0.0954773869346733, -0.0954115076474873,
>
> -0.0952380952380952, -0.0951115834218915, -0.0950642007303569,
>
> -0.0949423247559894, -0.0947368421052631, -0.0946291560102303,
>
> -0.0945220193340494, -0.0944309927360775, -0.0943016759776536,
>
> -0.0942720763723149, -0.0941770647653002, -0.0940298507462686,
>
> -0.094017094017094, -0.0935672514619884, -0.0934579439252337,
>
> -0.0930232558139535, -0.0929772502472798, -0.0929054054054054,
>
> -0.0928778745255637, -0.0927700348432055, -0.0925266903914591,
>
> -0.0922502666192677, -0.0918094218415418, -0.0915254237288135,
>
> -0.0914774596906876, -0.0914662894860915, -0.0914285714285715,
>
> -0.0912322274881517, -0.090909090909091, -0.0909090909090909,
>
> -0.09079754601227, 

[R] Empirical density estimation

2018-03-11 Thread Christofer Bogaso
Hi,

Let say I have below vector of data-points :

Dat = c(-0.444, -0.25, -0.237449799196787, -0.227467046669042,

-0.227454464682363, -0.22, -0.214876033057851, -0.211781206171108,

-0.199891067538126, -0.192920353982301, -0.192307692307692, -0.186046511627907,

-0.184418145956608, -0.181818181818182, -0.181818181818182, -0.181266261925412,

-0.181003118503119, -0.179064587973274, -0.178217821782178, -0.17809021675454,

-0.177685950413223, -0.177570093457944, -0.176470588235294, -0.176470588235294,

-0.174825741611282, -0.168021680216802, -0.167, -0.167,

-0.166380789022298, -0.164209115281501, -0.164011246485473, -0.162689804772234,

-0.162361623616236, -0.160161507402423, -0.16, -0.155038759689922,

-0.154172560113154, -0.15311004784689, -0.151515151515152, -0.151462994836489,

-0.151098901098901, -0.150537634408602, -0.150442477876106, -0.150406504065041,

-0.149904214559387, -0.149882903981265, -0.149797570850202, -0.148496240601504,

-0.148325358851675, -0.147540983606557, -0.147239263803681, -0.146989966555184,

-0.14622641509434, -0.146095717884131, -0.145994832041344, -0.14572864321608,

-0.145161290322581, -0.144292237442922, -0.144144144144144, -0.144021739130435,

-0.14375, -0.142212189616253, -0.141122913505311, -0.140324963072378,

-0.139344262295082, -0.13884007029877, -0.138356164383562, -0.137626262626263,

-0.137142857142857, -0.136690647482014, -0.136577708006279, -0.136363636363636,

-0.136094674556213, -0.135879774577332, -0.135586319218241, -0.135135135135135,

-0.132780082987552, -0.132209405501331, -0.132023755139333, -0.131233595800525,

-0.130434782608696, -0.130434782608696, -0.130268199233717, -0.128813559322034,

-0.1284046692607, -0.128205128205128, -0.128182616330114, -0.127937336814621,

-0.126283367556468, -0.125853658536585, -0.125448028673835, -0.125425564840607,

-0.125311203319502, -0.125, -0.124401913875598, -0.124248496993988,

-0.124031007751938, -0.123572170301142, -0.123188405797102, -0.122905027932961,

-0.1216667, -0.121573685907772, -0.120658135283364, -0.120540019286403,

-0.119858156028369, -0.11965811965812, -0.11965811965812, -0.119565217391304,

-0.118942731277533, -0.117820324005891, -0.116257947320618, -0.115789473684211,

-0.115683584819387, -0.115384615384615, -0.115281501340483, -0.114492753623188,

-0.114357262103506, -0.114285714285714, -0.114035087719298, -0.113181972212809,

-0.112790697674419, -0.112781954887218, -0.112195121951219, -0.112191473448018,

-0.111, -0.111, -0.110813226094727, -0.110384300899428,

-0.110147441457069, -0.110137672090113, -0.109913793103448, -0.109792284866469,

-0.109375, -0.10919540229885, -0.109112709832134, -0.10844250363901,

-0.107776617954071, -0.10752688172043, -0.107317073170732, -0.106674272675414,

-0.106382978723404, -0.106100795755968, -0.106060606060606, -0.10595160235448,

-0.105742474070326, -0.105263157894737, -0.104454685099846, -0.104283054003724,

-0.103916449086162, -0.103723404255319, -0.103448275862069, -0.102737680438029,

-0.10267471958585, -0.101696871753434, -0.100893997445721, -0.10041265474553,

-0.100042983021706, -0.1, -0.0995111731843576, -0.099502487562189,

-0.0994117647058824, -0.0991561181434598, -0.0989492119089317,

-0.0988372093023255, -0.0983908045977012, -0.0983050847457627,

-0.0977198697068404, -0.0974702380952382, -0.0973819695475956,

-0.097345132743363, -0.0971472629144179, -0.0971438645980254,

-0.0961538461538461, -0.096062667491239, -0.0957347238935687,

-0.0956521739130435, -0.0954773869346733, -0.0954115076474873,

-0.0952380952380952, -0.0951115834218915, -0.0950642007303569,

-0.0949423247559894, -0.0947368421052631, -0.0946291560102303,

-0.0945220193340494, -0.0944309927360775, -0.0943016759776536,

-0.0942720763723149, -0.0941770647653002, -0.0940298507462686,

-0.094017094017094, -0.0935672514619884, -0.0934579439252337,

-0.0930232558139535, -0.0929772502472798, -0.0929054054054054,

-0.0928778745255637, -0.0927700348432055, -0.0925266903914591,

-0.0922502666192677, -0.0918094218415418, -0.0915254237288135,

-0.0914774596906876, -0.0914662894860915, -0.0914285714285715,

-0.0912322274881517, -0.090909090909091, -0.0909090909090909,

-0.09079754601227, -0.0907071455016661, -0.0906593406593406,

-0.0903614457831325, -0.0903323548906352, -0.09, -0.0897243107769424,

-0.0896358543417368, -0.0895522388059702, -0.0895052902487847,

-0.0891719745222929, -0.0888, -0.0887227819304518,

-0.0887096774193548, -0.0886956521739131, -0.0884703196347032,

-0.0884450784593437, -0.0884413309982488, -0.0883577310155536,

-0.0883054892601431, -0.0882917466410749, -0.0881628999776236,

-0.0881193929739248, -0.0880681818181819, -0.0878186968838525,

-0.087719298245614, -0.0876010781671159, -0.0873634945397815,

-0.0872641509433961, -0.0871512228728901, -0.0871032050299035,

-0.0868133772309825, -0.0865384615384615, -0.0858895705521473,

-0.085742525327403, -0.0855766209280403, -0.0854700854700855,