Displaying 20 results from an estimated 20000 matches similar to: "hist() and density"
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
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
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:
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
2006 Aug 10
3
Multiple density curves
Hi,
I am new to R...a recent convert from SAS.
I have a dataset that looks like this:
SEQ A1 A2
A 532.5 554.5
B 25.5 35.5
C 265.2 522.2
D 245.55 521.56
E 546.52 141.52
F 243.25 32.56
G 452.55 635.56
H 15.14 16.54
I 543.4 646.56
J 54.4 654.5
K 646.5 64.54
L 645.4 614.46
M 646.54 634.46
I want to make a histogram
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,
2008 Dec 26
1
histogramm$density
hello,
i am using the hist function with classified values. The class breaks are >1, so
histogram$density is != 1.
How to plot the histogram with freq=FALSE and the real class density values.
I used:
> h2 = hist(value, breaks = breaks_vector)
> h2$density = round(h2$counts/sum(h2$counts), 2)
> h2$intensities = h2$density
> plot(h2, freq=F)
but this isn't the best way, i
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:
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
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
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
2009 Mar 02
4
density > 1?
Dear R-Gurus,
I wonder why 'density' values as shown in hist or plot(density(x)) are
sometimes over 1. How can that be?
Example
>hist(rnorm(1000,sd=.5),freq=FALSE)
The resulting plot shows density values below 1 on the y-axis. However,
>hist(rnorm(1000,sd=.1),freq=FALSE)
shows density values over 1.
How to interpret density values over 1?
Greetings,
Johannes
2005 Dec 13
8
superimpose density line over hist
Hi all,
I'm trying to superimpose a rchisq density line over a histogram with
something like:
hist(alnlength)
lines(density(rchisq(length(alnlength), 4)),col="red")
But the rchisq line won't appear anywhere,
Anyone knows what I am missing here?
Thanks in advance,
Albert.
1998 Jan 23
2
hist: rel.freqs
In R0.61,
In hist(), should the line
rel.freqs <- counts/(sum(x) * diff(breaks))
computing the relative frequencies or height of the rectangles
in a histogram not be
rel.freqs <- counts/(sum(counts) * diff(breaks))
instead, or do I misunderstand something?
Thanks,
Philippe
--
--------------------------------------------------------
Philippe Lambert Tel:
2008 Aug 07
2
histogram - freq=FALSE - density computation
Hi,
I don't understand what
hist(x, freq=FALSE)
does.
At first I thought it would be just the relative frequencies instead
of the absolute frequencies,
by just computing "frequencies / n" in every category.
But with a small dataset the y-values (densities) don't sum to one.
Is there a way to get the histogram doing that?
Or what is the idea of this density-computation?
2004 Aug 19
3
probability histogram question
Hello, all;
I get an unexpected result when trying to plot a probability histogram
with R1.9.1 on windows xp:
#with the following code:
> x <- runif(100,0,1)
> hist(x)
> hist(x, freq=F)
> h <- hist(x, freq=F)
> summary(h)
# Length Class Mode
#breaks 11 -none- numeric
#counts 10 -none- numeric
#intensities 10 -none- numeric
#density 10
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 =
2010 Mar 30
1
hist.default()$density
Dear developers,
the current implementation of hist.default() calculates 'density' (and
'intensities') as
dens <- counts/(n*h)
where h has been calculated before as
h <- diff(fuzzybreaks)
which results in 'fuzzy' values for the density, see e.g.
> tmp <- hist(1:10,breaks=c(-2.5,2.5,7.5,12.5),plot=FALSE)
> print(tmp$density,digits=15)
[1]
1998 Jul 03
1
R-beta: histogram
Can someone please tell me to make a density histogram?
hist makes one with count or relative frequency on the y-axis.
I want the density, which is (rel freq)/(bin width)
In the help I see:
intensities: values f^(x[i]), as estimated density values.
If `all(diff(breaks) == 1)', they are the relative
frequencies `counts/n' and in general satisfy
2003 Jun 17
1
hist density...
Hi!
Do not understand following behavior.
> summary(test$dif)
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.7389 0.9713 0.9850 0.9818 1.0000 1.0000
length(test$dif)
[1] 85879
tmp <- hist(test$dif,breaks=100,freq=FALSE)
The density on the Y axis in the plot are in the range 0-200.
Thought that the density should be in the range 0-1
(something like