Java NormalDistribution.density方法代码示例(javanormaldistribution.density方法的代码示例)

本文整理汇总了Java中org.apache.commons.math3.distribution.NormalDistribution.density方法的典型用法代码示例。如果您正苦于以下问题:Java NormalDistribution.density方法的具体用法?Java NormalDistribution.density怎么用?Java NormalDistribution.density使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.math3.distribution.NormalDistribution的用法示例。


Java NormalDistribution.density方法代码示例(javanormaldistribution.density方法的代码示例)

在下文中一共展示了NormalDistribution.density方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: univarNormal

import org.apache.commons.math3.distribution.NormalDistribution; //导入方法依赖的package包/类
public  RegDataSet univarNormal(){


        NormalDistribution normalDistribution = new NormalDistribution(0,1);

        RegDataSet dataSet = RegDataSetBuilder.getBuilder()
                .numDataPoints(numDataPoints)
                .numFeatures(1)
                .dense(true)
                .missingValue(false)
                .build();
        for (int i=0;i<numDataPoints;i++){
            double featureValue = Sampling.doubleUniform(-1,1);
            double label;
            label = normalDistribution.density(featureValue);
            label += noise.sample();
            dataSet.setFeatureValue(i,0,featureValue);
            dataSet.setLabel(i,label);
        }
        return dataSet;
    } 
开发者ID:cheng-li,项目名称:pyramid,代码行数:22,代码来源:RegressionSynthesizer.java

示例2: loadGaussianDistrib

import org.apache.commons.math3.distribution.NormalDistribution; //导入方法依赖的package包/类
/**
 * Define a symmetric pair of gaussian distributions around the origin.
 * @param offset: mean of gaussian this number of bp upstream for Watson strand and this number of bp downstream for Crick strand
 * @param gaussianSigma 
 */
public void loadGaussianDistrib(double offsetWatson, double gaussianSigmaWatson, double offsetCrick, double gaussianSigmaCrick){
	NormalDistribution wNorm = new NormalDistribution(offsetWatson, gaussianSigmaWatson);
	NormalDistribution cNorm = new NormalDistribution(offsetCrick, gaussianSigmaCrick);
	for(int i=left; i<=right; i++){
		watsonData[i-left] = wNorm.density(i);
		crickData[i-left] = cNorm.density(i);
	}
	makeProbabilities();
	isGaussian = true;
	gaussOffsetW = offsetWatson;
	gaussOffsetC = offsetCrick;
	gaussSigmaW = gaussianSigmaWatson;
	gaussSigmaC = gaussianSigmaCrick;
} 
开发者ID:seqcode,项目名称:chexmix,代码行数:20,代码来源:TagProbabilityDensity.java

示例3: solveNormalNewsvendor

import org.apache.commons.math3.distribution.NormalDistribution; //导入方法依赖的package包/类
public static Newsvendor solveNormalNewsvendor (final double price, final double cost, final double mu, final double sigma) {
	final NormalDistribution dist = new NormalDistribution();
	return new Newsvendor(price,cost) {{
		_safetyfactor = dist.inverseCumulativeProbability((price-cost)/price);
		_quantity = mu+sigma*_safetyfactor;
		_profit = (price-cost)*mu - price*sigma*dist.density(_safetyfactor);
	}
	@Override
	public double getProfit(double quantity) {
		double z = (quantity-mu)/sigma;
		double lostSales = sigma*(dist.density(z)-z*(1-dist.cumulativeProbability(z)));
		return _price*mu -_cost*quantity - _price*lostSales;
	}
	};
} 
开发者ID:loehndorf,项目名称:scengen,代码行数:16,代码来源:Newsvendor.java

示例4: createGaussianKernel

import org.apache.commons.math3.distribution.NormalDistribution; //导入方法依赖的package包/类
/**
 * 
 * @param size Number of pixels from 3 standard deviations from one side of the Guassian to the other.
 * @return
 */
public static float[][] createGaussianKernel(int size)
{
	if (size == 0)
	{
		return new float[][] {{1f}};
	}
	
	// I want the edge of the kernel to be 3 standard deviations away from
	// the middle. I also divide by 2 to get half of the size (the length from center to edge).
	double sd = size / (2.0 * 3.0);
	NormalDistribution dist = new NormalDistribution(0, sd);
	int resultSize = (size * 2);

	float[][] kernel = new float[resultSize][resultSize];
	for (int x : new Range(resultSize))
	{
		double xDistanceFromCenter = Math.abs(resultSize / 2.0 - (x));
		for (int y : new Range(resultSize))
		{
			double yDistanceFromCenter = Math.abs(resultSize / 2.0 - (y));
			// Find the distance from the center (0,0).
			double distanceFromCenter = Math.sqrt(xDistanceFromCenter
					* xDistanceFromCenter + yDistanceFromCenter
					* yDistanceFromCenter);
			kernel[y][x] = (float) dist.density(distanceFromCenter);
		}
	}
	normalize(kernel);
	return kernel;
} 
开发者ID:jeheydorn,项目名称:nortantis,代码行数:36,代码来源:ImageHelper.java

示例5: calculateSpatialEntropyWeights

import org.apache.commons.math3.distribution.NormalDistribution; //导入方法依赖的package包/类
/**
 * Calculate the max probability value applying the Gaussian functionon the
 * probability distribution
 * @param entropies : spatial entropy values of the terms
 * @return max weight
 */
private static Map<String, Double> calculateSpatialEntropyWeights(
		Map<String, Double>  entropies){
	
	double[] termSpatialEntropyValues = entropies
			.values().stream().mapToDouble(d -> d).toArray();
	
	NormalDistribution gd = new NormalDistribution( // Gaussian function for re-weighting
			new Mean().evaluate(termSpatialEntropyValues),
			new StandardDeviation().evaluate(termSpatialEntropyValues));
	
	Double gdMax = 0.0;
	Map<String, Double> weights = new HashMap<String, Double>();
	for(Entry<String, Double> p:entropies.entrySet()){
		double weight = gd.density(p.getValue());
		weights.put(p.getKey(), weight);
		if(gdMax < weight){
			gdMax = weight;
		}
	}
	
	for(Entry<String, Double> term:weights.entrySet()){
		term.setValue(term.getValue()/gdMax);
	}
			
	return Utils.sortByValues(weights);
} 
开发者ID:socialsensor,项目名称:multimedia-geotagging,代码行数:33,代码来源:Entropy.java

示例6: TruncatedNormal

import org.apache.commons.math3.distribution.NormalDistribution; //导入方法依赖的package包/类
public TruncatedNormal(RandomGenerator rng, double mu, double sigma, double lowerBound, double upperBound) {
    super(rng);
    this.mu = mu;
    this.sigma = sigma;
    this.lowerBound = lowerBound;
    this.upperBound = upperBound;
    unnormalized = new NormalDistribution(mu, sigma);
    if (upperBound < lowerBound) {
        throw new IllegalArgumentException("upper bound must be no lower than lower bound");
    }
    lowerZ = unnormalized.cumulativeProbability(lowerBound);
    upperZ = 1 - unnormalized.cumulativeProbability(upperBound);
    reZ = 1 - (lowerZ + upperZ);
    NormalDistribution standardNormal = new NormalDistribution();
    double alpha = (lowerBound - mu) / sigma;
    double beta = (upperBound - mu) / sigma;
    double phiAlpha = standardNormal.density(alpha);
    double phiBeta = standardNormal.density(beta);
    double zPhiAlpha = standardNormal.cumulativeProbability(alpha);
    double zPhiBeta = standardNormal.cumulativeProbability(beta);
    double denom = (zPhiBeta - zPhiAlpha);
    double c = (phiBeta - phiAlpha) / denom;
    mean = mu - sigma * c;
    double d = 1 - c * c;
    if (phiBeta > 0.0) d -= beta * phiBeta / denom;
    if (phiAlpha > 0.0) d += alpha * phiAlpha / denom;
    variance = (sigma * sigma) * d;
    
} 
开发者ID:mgormley,项目名称:pacaya,代码行数:30,代码来源:TruncatedNormal.java

示例7: getNormalDistribution

import org.apache.commons.math3.distribution.NormalDistribution; //导入方法依赖的package包/类
public static List<FederationDatacenter> getNormalDistribution(int numOfDatacenters, int numHost)
{
	Random r =  new Random(13213);
	
	int core_variance = maxNumOfCores - minNumOfCores;
	int delta_cores = core_variance > 0 ? r.nextInt(core_variance) : 0;
	
	List<FederationDatacenter> list = new ArrayList<FederationDatacenter>();
	NormalDistribution nd = new NormalDistribution(numOfDatacenters / 2d, numOfDatacenters / 4d);
	
	// System.out.println("Aa"+numHost);
	
	for (int i=0; i<numOfDatacenters; i++)
	{
		// create the virtual processor (PE)
		List<Pe> peList = new ArrayList<Pe>();
		int mips = 25000;
		for (int j=0; j<minNumOfCores + delta_cores; j++)
		{
			peList.add(new Pe(j, new PeProvisionerSimple(mips)));
		}
		

		// create the hosts
		List<Host> hostList = new ArrayList<Host>();
		HostProfile prof = HostProfile.getDefault();
		prof.set(HostParams.RAM_AMOUNT_MB, 16*1024+"");

		int num;
		if (numOfDatacenters == 1)
		{
			num = numHost;
		}
		else
		{
			Double value = new Double(nd.density(i)) * numHost;
			num = value.intValue();
		}
		
		if (num < 1)
			num = 1;

		for (int k=0; k<num; k++)
		{
			hostList.add(HostFactory.get(prof, peList));
		}
		
		// create the storage
		List<Storage> storageList = new ArrayList<Storage>(); // if empty, no SAN attached
		
		// create the datacenters
		list.add(FederationDatacenterFactory.getDefault(hostList, storageList));
	}
	
			
	return list;
} 
开发者ID:ecarlini,项目名称:smartfed,代码行数:58,代码来源:DatacenterFacilities.java

示例8: probability

import org.apache.commons.math3.distribution.NormalDistribution; //导入方法依赖的package包/类
static
public double probability(GaussianDistribution gaussianDistribution, Number x){
	NormalDistribution distribution = new NormalDistribution(gaussianDistribution.getMean(), Math.sqrt(gaussianDistribution.getVariance()));

	return distribution.density(x.doubleValue());
} 
开发者ID:jpmml,项目名称:jpmml-evaluator,代码行数:7,代码来源:DistributionUtil.java

示例9: probability

import org.apache.commons.math3.distribution.NormalDistribution; //导入方法依赖的package包/类
static
private double probability(double mean, double variance, double x){
	NormalDistribution distribution = new NormalDistribution(mean, Math.sqrt(variance));

	return distribution.density(x);
} 
开发者ID:jpmml,项目名称:jpmml-evaluator,代码行数:7,代码来源:TargetValueCountsTest.java

示例10: calculateDensityProbabilityNumericAttribute

import org.apache.commons.math3.distribution.NormalDistribution; //导入方法依赖的package包/类
private double calculateDensityProbabilityNumericAttribute(RuleTerm ruleTerm, NormalDistribution normalDistribution){
	
	// Cumulative probability for given class label
	double DensityProbability = normalDistribution.density(ruleTerm.value);
	
	return DensityProbability;
} 
开发者ID:thienle2401,项目名称:G-eRules,代码行数:8,代码来源:GeRules.java

示例11: findLowerUpperNumericAttributeForClassLabel

import org.apache.commons.math3.distribution.NormalDistribution; //导入方法依赖的package包/类
private double[] findLowerUpperNumericAttributeForClassLabel(NormalDistribution normalDistribution, Attribute attribute, ArrayList<Instance> instancesList){
	
	// density probaility for each numeric value from the attribute from the dataset
	TreeMap<Double, Double>	densityProbabilitiesOfValues = new TreeMap<>();
	
	for (Instance instance : instancesList) {
		
		// get value of the attribute from an instance
		double valueOfAttribute = instance.value(attribute);
		
		// calculate density probability
		double densityProbability = normalDistribution.density(valueOfAttribute);
		
		// add to density probability map to find the best later
		densityProbabilitiesOfValues.put(densityProbability, valueOfAttribute);
		
	}
	
	double valueWithBestDensityProbability = densityProbabilitiesOfValues.lastEntry().getValue();
	
	TreeMap<Double, Double> smallerSideOfValueWithBestProbability = new TreeMap<>();
	TreeMap<Double, Double> greaterSideOfValueWithBestProbability = new TreeMap<>();

	// work out list of values and their corresponding density probability
	for (Entry<Double, Double> probabilityValueEntry : densityProbabilitiesOfValues.entrySet()) {
		
		// value greater than best value should be added to greater side
		if(probabilityValueEntry.getValue() > valueWithBestDensityProbability){
			
			greaterSideOfValueWithBestProbability.put(probabilityValueEntry.getKey(), probabilityValueEntry.getValue());
			
		}
		// otherwise, should be added to smaller side
		else if (probabilityValueEntry.getValue() < valueWithBestDensityProbability){
			
			smallerSideOfValueWithBestProbability.put(probabilityValueEntry.getKey(), probabilityValueEntry.getValue());
		}
		
		
	}
	
	double[] boundsForAttribute = new double[2];
	


	
	if(smallerSideOfValueWithBestProbability.isEmpty()){
		boundsForAttribute[0] = valueWithBestDensityProbability;
	}else{
		boundsForAttribute[0] = smallerSideOfValueWithBestProbability.lastEntry().getValue();
	}
	
	if(greaterSideOfValueWithBestProbability.isEmpty()){
		boundsForAttribute[1] = valueWithBestDensityProbability;
	}else{
		boundsForAttribute[1] = greaterSideOfValueWithBestProbability.lastEntry().getValue();
	}
	
	return boundsForAttribute;
	
} 
开发者ID:thienle2401,项目名称:G-eRules,代码行数:62,代码来源:GeRules.java

本文标签属性:

示例:示例英语

代码:代码转换器

java:java面试题

NormalDistribution:NormalDistribution

density:density中文翻译

上一篇:怎样制作抖音短视频(怎么在抖音发短视频挣钱)(如何制作抖音短视频)
下一篇:Java SQLASTVisitor.visit方法代码示例

为您推荐