/**
* This file is part of
*
* Uranus - Universal RAndom NUmber Service
*
* Copyright (C) 2011 Center for Environmental Systems Research, Kassel, Germany
*
* Uranus - Universal RAndom NUmber Service is free software:
* You can redistribute it and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* Uranus - Universal RAndom NUmber Service is distributed in
* the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Center for Environmental Systems Research, Kassel
*/
package de.cesr.uranus.dist;
import org.apache.log4j.Logger;
import cern.jet.random.Normal;
import cern.jet.random.engine.RandomEngine;
import de.cesr.uranus.core.URandomService;
import de.cesr.uranus.util.UIdentifyCallerException;
/**
* Uranus - Universal RAndom NUmber Service
*/
public class UNormalController extends Normal {
/**
* @param mean
* @param std
* @param engine
*/
public UNormalController(double mean, double std, RandomEngine engine) {
super(mean, std, engine);
}
/**
*
*/
private static final long serialVersionUID = -6348861089817698692L;
/**
* Logger
*/
static private Logger logger_st = Logger.getLogger(URandomService.class.getName() + ".stacktrace");
static private Logger logger = Logger.getLogger(URandomService.class);
@Override
public double nextDouble() {
double rand = super.nextDouble();
// logging is done by nextDouble(mean, std) that is called by the super method!
return rand;
}
/**
* Returns a uniformly distributed random number in the open interval <tt>(from,to)</tt> (excluding <tt>from</tt>
* and <tt>to</tt>). Pre conditions: <tt>from <= to</tt>.
*/
@Override
public double nextDouble(double mean, double std) {
double rand = super.nextDouble(mean, std);
logger.debug(URandomService.getURandomService().identifyDistribution(
this)
+ "> Normal (mean: "
+ mean
+ "/std: "
+ std
+ "Random number: "
+ rand
+ " (generator: "
+ URandomService.getURandomService().identifyGenerator(
randomGenerator) + ")");
logger_st.error("Stack trace: ", new UIdentifyCallerException());
return rand;
}
public static double staticNextDouble(double mean, double std) {
double rand = Normal.staticNextDouble(mean, std);
logger.debug("Static call> Normal (mean: "
+ mean
+ "/std: "
+ std
+ "Random number: "
+ rand
+ " (generator: Static call)");
logger_st.error("Stack trace: ", new UIdentifyCallerException());
return rand;
}
}