Displaying 20 results from an estimated 10000 matches similar to: "hist densities"
2008 Mar 21
1
hist densities
Hi there,
I was wondering why
x<-rnorm(n=5000,mean=1.5,sd=0.25)
h<-hist(x)
sum(h$density)
[1] 10
I thought the integral of the histogram should be one? These seems
strange to me, or am I being silly...
Regards Luke Spadavecchia
PS. I'm using R 2.5.1 on Mac OSX
2001 Oct 18
0
Numerical precision of hist densities or cumsum?
Today I wanted to experiment with different distributions an to see the
hazard rates they imply. So I eventually ended up with this, which uses
the hist object's handy $density and the cumsum function in R:
x <- c(rweibull(21000,0.5,0.7))
#create "breaks" vector to go into histogram
#need last break bigger than max(x)
y <- seq(0,max(x)+2)
histx <-
2009 Jun 04
1
hist returning density larger than 1
The following code is giving me problems. I want to export densities
of a distribution to a csv file. At the bottom of the code I use the
hist function to generate the densities. But hist is returning values
greater than 1. I don't understand, why. Any help you can supply is
greatly appreciated.
# Set word path
dir<-"~/Research/MR Distribution Analysis/"
setwd(dir)
2000 Nov 17
2
hist() and density
There were some questions about hist() a couple of days ago which
triggered this post. My question/suggestion is about the y-axis in hist.
There are reasons to prefer making the y-axis density=relative
frequency/bin width. One reason is that the height of the plot does not
depend on the bin width; another is that if your histogram is in density
then you can easily superimpose a smooth theoretical
2009 Jul 26
2
problems hist() and density
Hello,
I have a problem with the hist() function and showing densities. The
densities sum to 50 and not to 1! I use R version 2.9.1 (2009-06-26) and
I load the seqinR library.
My data is the following vector:
[1] 0.1400000 0.2000000 0.2200000 0.2828283 0.1600000 0.1600000
0.3600000
[8] 0.1600000 0.2200000 0.2600000 0.2000000 0.3000000 0.2200000
0.2342342
[15] 0.1800000 0.2200000 0.1600000
1997 Dec 23
0
R-beta: bug in hist() (0.60/0.61)
I discovered a bug in hist().
Try the following:
x<-c(-5,-4,-4,-4,-3,-3,-3,-3,-2,-2,0,0,0,0,1,1,1,3,3,5,6)
# Note that sum(x)<0:
sum(x)
# [1] -13
hist(x)
# looks ok
hist(x,freq=F)
# negative bars !!
# and finally this gives not 1:
sum(hist(x,plot=F)$rel.freqs)
# [1] -0.8076923
The reason is, that "sum(x)" is used instead of "length(x)" in the following
line near
2011 Jun 09
1
histogram - density on y axis and restriction to interval [0, 1]
Hello,
To indicate probability densities instead of counts on a histogram, I
specify freq = FALSE.
However, I expect that summing all top y coordinates over all the
intervals of the histogram will provide 1.
1)
v <- c(0.2885, 0.2988, 0.3139, 0.2615, 0.3179, 0.3163, 0.2583, 0.3052,
0.2527, 0.3147, 0.3235, 0.2408, 0.2480, 0.3108, 0.3577, 0.2829, 0.2694,
0.3275, 0.3314, 0.2639, 0.3076,
2006 May 18
0
?hist and $density explanation
Hi, people. Within ?hist (using R 2.3.0), one reads:
density: values f^(x[i]), as estimated density values. If
'all(diff(breaks) == 1)', they are the relative frequencies
'counts/n' and in general satisfy sum[i; f^(x[i])
(b[i+1]-b[i])] = 1, where b[i] = 'breaks[i]'.
I trip on this explanation each time I read it. Some R guardians will
be
2006 Apr 05
1
hist function: freq=FALSE for standardised histograms
Dear All,
I am a undergraduate using R for the first time. It seems like an excellent
program and one that I look forward to using a lot over the next few years,
but I have hit a very basic problem that I can't solve.
I want to produce a standardised histogram, i.e. one where the area under
the graph is equal to 1. I look at the manual for the histogram function and
find this:
freq:
2004 Nov 26
2
hist and truehist
Hello!
Up to now I have been using hist() to display the distributions.
Howevere, I noteiced strange numbers on y (vertical) axis, if I used
probability = T or freq = F option. I thought it is a bug and launched
the R-bug system and found some posts on that matter. Brian Ripley
responded to one, that one should look at truehist() for that. Ok I can
use truehist() if I want to see the ratios
2004 Aug 21
1
relative frequencies for hist()
I have problems getting a histogram with relative frequencies on the y-axis.
Here is an example data set:
> a <- c(4.626, 4.627, 4.627, 4.628, 4.629, 4.629, 4.630, 4.631, 4.632,
4.632)
> d = hist(a,freq=F)
> d$density
[1] 299.9999 100.0000 200.0000 100.0000 100.0000 200.0000
The obtained densities are given by counts/(total n * bin width), with
bin width being
2010 Mar 13
2
Is this a bug (or a feature) in hist(x)$density ??
Hi all,
A friend send me a question on why does this:
x<-rpois(100,1)
sum( hist(x)$density )
Gives out "2"
I tried this:
sum( hist(x, freq =T)$density )
It didn't help.
Then he came back with the following insight:
# with breaks
b<-c(0,0.9,1:8)
sum(hist(x,breaks=b)$density) # Much more then 2
# but if we add weights according to the interval length
2009 Aug 19
1
Fw: Hist & kernel density estimates
For the hist estimate
>par(mex=1.3)
>dens<-density(q)
>options(scipen=4)
> ylim<-range(dens$y)
> h<-hist(q,breaks="scott",freq=FALSE,probability=TRUE,
+? right=FALSE,xlim=c(9000,16000),ylim=ylim,main="Histogram of q(scott)")
> lines(dens)
>box()
?
For the kernel estimate>options(scipen=4)
> d <- density(q, bw =
2011 Jan 13
3
Question about histogram
Dear list,
I'm new to R, please bear with my silly questions. I'm trying to get an
understanding of why the results I get from a call to hist() are not as
I thought I would get. When I use the parameter freq=FALSE, I think the
plot will contain bars that none of them is larger than 1, because
they're probabilities. But for my code, the bars exceeded 1.
The actual data seems
2005 Dec 11
1
(PR#8376 inconsistency between plot(hist(...)) and hist(...)
On Sun, 11 Dec 2005 clausen at econ.upenn.edu wrote:
> Full_Name: Andrew Clausen
> Version: 2.1.0
> OS: Debian GNU/Linux
> Submission from: (NULL) (71.242.192.73)
>
>
> Hi,
>
> When I type
>
> hist(x, freq=F)
>
> I get a density function, as I expect. However, if I type
>
> plot(hist(x, freq=F))
>
> then I get the same output as if I had
2013 Jan 22
3
density of hist(freq = FALSE) inversely affected by data magnitude
Hi,
I have a couple of observations, a question or two, and perhaps a
suggestion related to the plotting of density on the y-axis within the
hist() function when freq=FALSE. I was using the function and trying
to develop an intuitive understanding of what the density is telling
me. After reading through this fairly helpful post:
2003 Mar 08
2
hist() basic question
Hi,
This is a very basic question, but I would like to undestand hist(). I
thought that the hist( , freq=FALSE) should provide the relative
frequencies (probabilities), and so they should sum 1, however:
set.seed(2)
ah <- hist(rnorm(100), freq=F)
sum(ah$intensities)
[1] 2
set.seed(2)
bh <- hist(rlnorm(100), freq=F)
sum(bh$intensities)
[1] 0.4999996
I'm getting similar figures with
2002 Oct 03
0
[Fwd: curiousity with hist]
just realized that the bin value is actually the relative frequency
divided by the bin width. sorry for consuming band width.
Alas, is there anyway to make hist() calculate relative frequencies
irrespective of bin width?
thanks
Murad Nayal wrote:
>
> Hello,
>
> I am rather new to R. in trying to use the hist() command I get behavior
> that is somewhat puzzling me, in short,
2003 Jan 08
1
Determining the break points by hist() leads to errors (PR#2432)
Hi,
if I dermine the break points using the hist() function and then try
to re-use these in a new histogram, R fails. Here is an example of the
problem:
##First, plot a histogram:
data(islands)
foo <- hist(islands,freq=T)
##Now, try plot it again, with the previously determined break points:
hist(islands,breaks=foo$breaks,freq=T)
##... this lead to the warning message:
Warning message:
2013 Mar 26
2
Feed rle() output to hist()
I want to make a histogram from the lengths vector which is part of the
output of rle. But I don't know how to access that vector so that I use it
as an argument of hist(). What argument must I use so that I use the
lengths vector as an input to hist()?
Example output is:
Run Length Encoding
lengths: int [1:4] 1 2 3 3
values : num [1:4] -1 1 -1 1
A printout of the function rle() may