Package fork.lib.math.algebra.elementary.function.v1.distr

Examples of fork.lib.math.algebra.elementary.function.v1.distr.NormalDistribution


* @param sigma   standard deviation
* @return  
*/
public FunctionV1 kernelDensityEstimation(double sigma){
    try{
        FunctionV1 fn= new ConstantFunction(0);
        Iterator<Double> it= cs.keySet().iterator();
        while(it.hasNext()){
            Double v= it.next();
            Integer f= cs.get(v);
            double coeff= (double) f.intValue()/size();
            fn= fn.add( (new NormalDistribution( v.doubleValue(), sigma)).
                    multiply(new ConstantFunction(coeff)) );
        }
        return fn;
    }catch(FunctionException e){
        e.printStackTrace();
View Full Code Here


* @param coeffs
* @return
* @throws FunctionException
*/
public static double logLikelihood(Distribution data, ArrayList<DistributionFunction> distrs, ArrayList<Double> coeffs) throws FunctionException{
    FunctionV1 fn= new ConstantFunction(0);
    for( int i=0; i<distrs.size(); i++ ){
        fn = fn.add( distrs.get(i).multiply(new ConstantFunction(coeffs.get(i))) );
    }
    return data.logLikelihood(fn);
}
View Full Code Here

    double mm= Double.POSITIVE_INFINITY;
    double ms= Double.POSITIVE_INFINITY;
    if(res!=null){
        ArrayList<DistributionFunction> distrs= res.distrs;
        for( int i=0; i<distrs.size(); i++ ){
            DistributionFunction df= distrs.get(i);
            NormalDistributionParam param= (NormalDistributionParam)df.getParameters();
            if(param.mu<mm){
                mm= param.mu;
                ms= param.sigma;
            }
        }
View Full Code Here

        Iterator<Double> it= cs.keySet().iterator();
        while(it.hasNext()){
            Double v= it.next();
            Integer f= cs.get(v);
            double coeff= (double) f.intValue()/size();
            fn= fn.add( (new NormalDistribution( v.doubleValue(), sigma)).
                    multiply(new ConstantFunction(coeff)) );
        }
        return fn;
    }catch(FunctionException e){
        e.printStackTrace();
View Full Code Here




public static void main(String[] args) throws Exception { //debug
    NormalDistribution n= new NormalDistribution(10,5);
    Distribution d= new Distribution(
            0,0,0,0,1,1,1,1,1.2,1.2,1.3,2,2,3,5,6,7,
            10,10,10,10,11,11,11,11,12,12,12,14,13,13
            );
    d.add(20, 5); d.add(21, 10); d.add(22, 8);
View Full Code Here

* @return
*/
protected double threshold() throws EMException, DistributionException, FunctionException{
    Distribution d= new Distribution(data.getValues());
    DistributionFunction[] fn= new DistributionFunction[]{
        new NormalDistribution(0,1),
        new NormalDistribution(0,1)
    };
    EM em= new EM(d, fn, null);
    EMResultEntry res= em.getOptimalResultEntry();
    double mm= Double.POSITIVE_INFINITY;
    double ms= Double.POSITIVE_INFINITY;
View Full Code Here

protected ArrayList<DistributionFunction> findStartDistrs() throws EMException, DistributionException{
    ArrayList<DistributionFunction> ret= new ArrayList<>();
    ArrayList<Distribution> subs= data.quantileSubsets(types.length);
    for(int i=0;i<types.length;i++){
        if(types[i] instanceof NormalDistribution){
            ParameterEstimation pe = new ParameterEstimation(subs.get(i), new NormalDistribution(0, 1));
            ret.add(pe.funcOut);
        } else if(types[i] instanceof NormalDistribution){
            throw new EMException();
        } else {
            throw new EMException();
View Full Code Here

    d.add(7, 5); d.add(8, 8); d.add(9, 10); d.add(10,5);
    d.add(20, 5); d.add(21, 10); d.add(22, 8);
    d.add(120, 5); d.add(121, 10); d.add(122, 8);
   
    DistributionFunction[] types= new DistributionFunction[]{
        new NormalDistribution(0,1),
        new NormalDistribution(0,1),
        new NormalDistribution(0,1),
        //new NormalDistribution(0,1),
        new NormalDistribution(0,1)
    };
   
   
    EM em= new EM(d, types, null);
    em.start();
View Full Code Here

    double ms= Double.POSITIVE_INFINITY;
    if(res!=null){
        ArrayList<DistributionFunction> distrs= res.distrs;
        for( int i=0; i<distrs.size(); i++ ){
            DistributionFunction df= distrs.get(i);
            NormalDistributionParam param= (NormalDistributionParam)df.getParameters();
            if(param.mu<mm){
                mm= param.mu;
                ms= param.sigma;
            }
        }
View Full Code Here

protected ArrayList<DistributionFunction> findStartDistrs() throws EMException, DistributionException{
    ArrayList<DistributionFunction> ret= new ArrayList<>();
    ArrayList<Distribution> subs= data.quantileSubsets(types.length);
    for(int i=0;i<types.length;i++){
        if(types[i] instanceof NormalDistribution){
            ParameterEstimation pe = new ParameterEstimation(subs.get(i), new NormalDistribution(0, 1));
            ret.add(pe.funcOut);
        } else if(types[i] instanceof NormalDistribution){
            throw new EMException();
        } else {
            throw new EMException();
View Full Code Here

TOP

Related Classes of fork.lib.math.algebra.elementary.function.v1.distr.NormalDistribution

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.