In this paper we present a new approach to calibrate sensors in sensor networks in an uncontrolled environment. The proposed algorithm makes a model of the distribution of the measured quantity. This model can be used to estimate and correct the bias of the sensor. The proposed, centralized calibration algorithm is a macro-calibration algorithm which tries to improve the system response as a whole, instead of optimizing the response of an individual sensor. The algorithm decides, based on measurements to apply the calculated corrections or not. Testing shows the algorithm can be applied on e.g. temperature sensors. Systematic measurement errors can be reduced. A combination of a few accurate (expensive) sensors, and a large amount of less accurate (cheap) sensors, can be used together with the algorithm in real life applications to improve the quality of the measurements