histogram

entropy estimation using histogram of normal data vs direct formula (matlab)

こ雲淡風輕ζ 提交于 2019-12-22 09:09:53
问题 Let's assume we have drawn n=10000 samples of the standard normal distribution. Now I want to calculate its entropy using histograms to calculate the probabilities. 1) calculate probabilities (for example using matlab) [p,x] = hist(samples,binnumbers); area = (x(2)-x(1))*sum(p); p = p/area; (binnumbers is determined due to some rule) 2) estimate entropy H = -sum(p.*log2(p)) which gives 58.6488 Now when i use the direct formula to calculate the entropy of normal data H = 0.5*log2(2*pi*exp(1))

Histogram bar hiding tics

我与影子孤独终老i 提交于 2019-12-22 08:52:06
问题 I'm plotting a histogram in gnuplot and the bars end up covering the tics in the x axis, like so: Is there any way to prevent this? 回答1: I don't know for sure if this will work or not, but you can try this: set grid noxtics noytics noztics front From reading the documentation, it looks like that will push the tics to the top of the stack of objects when plotting (i.e. they'll get plotted after the bars making them visible (I think) ). Another option is to use transparency in your fillstyle,

Drawing histogram of CGImage in Swift 3

血红的双手。 提交于 2019-12-22 08:12:36
问题 I have a problem with vImageHistogramCalculation_ARGB8888 method while trying to convert library from Swift 2 to Swift 3 version. The problem is that the method accepts "histogram" argument only as UnsafeMutablePointer<UnsafeMutablePointer<T>?> but Swift 3 construction let histogram = UnsafeMutablePointer<UnsafeMutablePointer<vImagePixelCount>>(mutating: rgba) return unwrapped value, so I can't cast it to properly type. The compiler error is: : Cannot invoke initializer for type

Vertical Histogram in Python and Matplotlib

会有一股神秘感。 提交于 2019-12-22 03:51:11
问题 How can I make a vertical histogram. Is there any option for that or should it be built from the scratch? What I want is the upper graph to look like the below one but on vertical axis! from matplotlib import pyplot as plt import numpy as np sample=np.random.normal(size=10000) vert_hist=np.histogram(sample,bins=30) ax1=plt.subplot(2,1,1) ax1.plot(vert_hist[0],vert_hist[1][:-1],'*g') ax2=plt.subplot(2,1,2) ax2.hist(sample,bins=30) plt.show() 回答1: Use orientation="horizontal" in ax.hist : from

R - Shading part of a ggplot2 histogram

寵の児 提交于 2019-12-21 20:31:42
问题 So I have this data: dataset = rbinom(1000, 16, 0.5) mean = mean(dataset) sd = sd(dataset) data_subset = subset(dataset, dataset >= (mean - 2*sd) & dataset <= (mean + 2*sd)) dataset = data.frame(X=dataset) data_subset = data.frame(X=data_subset) And here's how I'm drawing my histogram for dataset : ggplot(dataset, aes(x = X)) + geom_histogram(aes(y=..density..), binwidth=1, colour="black", fill="white") + theme_bw() How can I shade the data_subset portion of the histogram, like so? 回答1: My

How to plot a histogram with a custom distribution?

戏子无情 提交于 2019-12-21 20:25:24
问题 In an old statistics textbook, I found a table of a distribution of ages for a country's population: Percent of Age population ------------------ 0-5 8 5-14 18 14-18 8 18-21 5 21-25 6 25-35 12 35-45 11 45-55 11 55-65 9 65-75 6 75-85 4 I wanted to plot this distribution as a histogram in R, with the age ranges as breaks and the percent of population as the density, but there didn't seem to be a straightforward way to do it. R's hist() function wants you to supply the individual data points,

Any way to create histogram with matplotlib.pyplot without plotting the histogram?

拥有回忆 提交于 2019-12-21 11:45:10
问题 I am using matplotlib.pyplot to create histograms. I'm not actually interested in the plots of these histograms, but interested in the frequencies and bins (I know I can write my own code to do this, but would prefer to use this package). I know I can do the following, import numpy as np import matplotlib.pyplot as plt x1 = np.random.normal(1.5,1.0) x2 = np.random.normal(0,1.0) freq, bins, patches = plt.hist([x1,x1],50,histtype='step') to create a histogram. All I need is freq[0] , freq[1] ,

Can't add a probability-curve on the histogram

会有一股神秘感。 提交于 2019-12-21 05:50:14
问题 I'm trying do display multiple histograms with one plot with the lattice-package. That's my code so far: histogram(~ X1 + X2 + X3 + X4 + X5 + X6 + X7 + X8 + X9 + X10, data=mydata, type = "density",layout=c(5,2), panel=function(x, ...) { panel.histogram(x, ...) panel.mathdensity(dmath=dnorm, col="black", args=list(mean=mean(x), sd=sd(x)), ...) }) The problem is, that it won't plot the probability-curve. It doesn't give me an error back, so the code looks good, I think. I also tried it with

R: ggplot2: Adding count labels to histogram with density overlay

二次信任 提交于 2019-12-21 05:45:13
问题 I have a time-series that I'm examining for data heterogeneity, and wish to explain some important facets of this to some data analysts. I have a density histogram overlayed by a KDE plot (in order to see both plots obviously). However the original data are counts, and I want to place the count values as labels above the histogram bars. Here is some code: $tix_hist <- ggplot(tix, aes(x=Tix_Cnt)) + geom_histogram(aes(y = ..density..), colour="black", fill="orange", binwidth=50) + xlab("Bin") +

Binning an array in javascript for a histogram

隐身守侯 提交于 2019-12-21 05:20:34
问题 I have below array in Javascript which I need to bin into 20 buckets. The data values are between 0 and 1, so the bin size would be .05. I feel like there should be a function out there that takes two arguments, an array and a bin size, but I cannot find one. I know that D3.js has some feature that help building such an array, but I cannot figure out which function might help. var arr = [ "0.362743", "0.357969", "0.356322", "0.355757", "0.358511", "0.357218", "0.356696", "0.354579", "0.828295