All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.TKnudsen.ComplexDataObject.model.weighting.Integer.GaussianIntegerWeightingFunction Maven / Gradle / Ivy

Go to download

A library that models real-world objects in Java, referred to as ComplexDataObjects. Other features: IO and preprocessing of ComplexDataObjects.

There is a newer version: 0.2.13
Show newest version
package com.github.TKnudsen.ComplexDataObject.model.weighting.Integer;

/**
 * 

* Title: GaussianWeightingFunction *

* *

* Description: Provides a weighting for a given interval, the center of the * values is defined by a reference (default: 0.0). The variance defines the * diversity of the kernel. *

* *

* Copyright: Copyright (c) 2016 *

* * @author Juergen Bernard * @version 1.0 */ public class GaussianIntegerWeightingFunction implements IIntegerWeightingKernel { private Integer interval = Integer.MAX_VALUE; private Integer reference = 0; private Double variance; public GaussianIntegerWeightingFunction(Double variance) { this.variance = variance; } @Override public double getWeight(Integer t) { if (Math.abs(reference - t) > interval) return 0.0; if (interval == 0) return 1.0; return gaussian(t); } /** * * @param a * @param b * @param x * @return */ public double gaussian(double x) { double a = 1 / (variance * Math.sqrt(2 * Math.PI)); return a * Math.exp(-Math.pow((x - reference), 2) / (2 * Math.pow(variance, 2))); } @Override public Integer getReference() { return reference; } @Override public void setReference(Integer t) { this.reference = t; } public Double getVariance() { return variance; } public void setVariance(Double variance) { this.variance = variance; } @Override public Integer getInterval() { return this.interval; } @Override public void setInterval(Integer interval) { this.interval = interval; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy