Fitting a histogram with python

Here you have an example working on py2.6 and py3.2: from scipy.stats import norm import matplotlib.mlab as mlab import matplotlib.pyplot as plt # read data from a text file. One number per line arch = “test/Log(2)_ACRatio.txt” datos = [] for item in open(arch,’r’): item = item.strip() if item != ”: try: datos.append(float(item)) except ValueError: pass … Read more

Android How to draw a smooth line following your finger

An easy solution, as you mentioned, is to simply connect the points with a straight line. Here’s the code to do so: public void onDraw(Canvas canvas) { Path path = new Path(); boolean first = true; for(Point point : points){ if(first){ first = false; path.moveTo(point.x, point.y); } else{ path.lineTo(point.x, point.y); } } canvas.drawPath(path, paint); } … Read more

How to fit a smooth curve to my data in R?

I like loess() a lot for smoothing: x <- 1:10 y <- c(2,4,6,8,7,12,14,16,18,20) lo <- loess(y~x) plot(x,y) lines(predict(lo), col=”red”, lwd=2) Venables and Ripley’s MASS book has an entire section on smoothing that also covers splines and polynomials — but loess() is just about everybody’s favourite.

Fitting a density curve to a histogram in R

If I understand your question correctly, then you probably want a density estimate along with the histogram: X <- c(rep(65, times=5), rep(25, times=5), rep(35, times=10), rep(45, times=4)) hist(X, prob=TRUE) # prob=TRUE for probabilities not counts lines(density(X)) # add a density estimate with defaults lines(density(X, adjust=2), lty=”dotted”) # add another “smoother” density Edit a long while … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)