• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Gaussian类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.commons.math3.analysis.function.Gaussian的典型用法代码示例。如果您正苦于以下问题:Java Gaussian类的具体用法?Java Gaussian怎么用?Java Gaussian使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Gaussian类属于org.apache.commons.math3.analysis.function包,在下文中一共展示了Gaussian类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testNormalDistributionWithLargeSigma

import org.apache.commons.math3.analysis.function.Gaussian; //导入依赖的package包/类
@Test
public void testNormalDistributionWithLargeSigma() {
    final double sigma = 1000;
    final double mean = 0;
    final double factor = 1 / (sigma * FastMath.sqrt(2 * FastMath.PI));
    final UnivariateFunction normal = new Gaussian(factor, mean, sigma);

    final double tol = 1e-2;
    final IterativeLegendreGaussIntegrator integrator =
        new IterativeLegendreGaussIntegrator(5, tol, tol);

    final double a = -5000;
    final double b = 5000;
    final double s = integrator.integrate(50, normal, a, b);
    Assert.assertEquals(1, s, 1e-5);
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:17,代码来源:IterativeLegendreGaussIntegratorTest.java


示例2: testGaussian

import org.apache.commons.math3.analysis.function.Gaussian; //导入依赖的package包/类
@Test
public void testGaussian() {
    FiniteDifferencesDifferentiator differentiator =
            new FiniteDifferencesDifferentiator(9, 0.02);
    UnivariateDifferentiableFunction gaussian = new Gaussian(1.0, 2.0);
    UnivariateDifferentiableFunction f =
            differentiator.differentiate(gaussian);
    double[] expectedError = new double[] {
        6.939e-18, 1.284e-15, 2.477e-13, 1.168e-11, 2.840e-9, 7.971e-8
    };
   double[] maxError = new double[expectedError.length];
    for (double x = -10; x < 10; x += 0.1) {
        DerivativeStructure dsX  = new DerivativeStructure(1, maxError.length - 1, 0, x);
        DerivativeStructure yRef = gaussian.value(dsX);
        DerivativeStructure y    = f.value(dsX);
        Assert.assertEquals(f.value(dsX.getValue()), f.value(dsX).getValue(), 1.0e-15);
        for (int order = 0; order <= yRef.getOrder(); ++order) {
            maxError[order] = FastMath.max(maxError[order],
                                    FastMath.abs(yRef.getPartialDerivative(order) -
                                                 y.getPartialDerivative(order)));
        }
    }
    for (int i = 0; i < maxError.length; ++i) {
        Assert.assertEquals(expectedError[i], maxError[i], 0.01 * expectedError[i]);
    }
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:27,代码来源:FiniteDifferencesDifferentiatorTest.java


示例3: testGaussian

import org.apache.commons.math3.analysis.function.Gaussian; //导入依赖的package包/类
@Test
public void testGaussian() {
    FiniteDifferencesDifferentiator differentiator =
            new FiniteDifferencesDifferentiator(9, 0.02);
    UnivariateDifferentiableFunction gaussian = new Gaussian(1.0, 2.0);
    UnivariateDifferentiableFunction f =
            differentiator.differentiate(gaussian);
    double[] expectedError = new double[] {
        2.776e-17, 1.742e-15, 2.385e-13, 1.329e-11, 2.668e-9, 8.873e-8
    };
   double[] maxError = new double[expectedError.length];
    for (double x = -10; x < 10; x += 0.1) {
        DerivativeStructure dsX  = new DerivativeStructure(1, maxError.length - 1, 0, x);
        DerivativeStructure yRef = gaussian.value(dsX);
        DerivativeStructure y    = f.value(dsX);
        for (int order = 0; order <= yRef.getOrder(); ++order) {
            maxError[order] = FastMath.max(maxError[order],
                                    FastMath.abs(yRef.getPartialDerivative(order) -
                                                 y.getPartialDerivative(order)));
        }
    }
    for (int i = 0; i < maxError.length; ++i) {
        Assert.assertEquals(expectedError[i], maxError[i], 0.01 * expectedError[i]);
    }
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:26,代码来源:FiniteDifferencesDifferentiatorTest.java


示例4: createGaussianFilter

import org.apache.commons.math3.analysis.function.Gaussian; //导入依赖的package包/类
private static double[] createGaussianFilter(int width) {
	int filterWidth = width;
	if (filterWidth % 2 == 0) {
		filterWidth++;
	}
	filterWidth = Math.max(1, filterWidth);
	double[] filter = new double[filterWidth];
	double sigma = Math.sqrt((filterWidth * filterWidth - 1.0) / 12.0);
	int mean = filterWidth / 2;
	double filterSum = 0.0;
	Gaussian gaussian = new Gaussian(mean, sigma);
	for (int i = 0; i < filterWidth; i++) {
		filter[i] = gaussian.value(i);
		filterSum += filter[i];
	}

	// normalize to 1
	for (int i = 0; i < filterWidth; i++) {
		filter[i] = filter[i] / filterSum;
	}

	return filter;
}
 
开发者ID:joakimkistowski,项目名称:LIMBO,代码行数:24,代码来源:ModelExtractor.java


示例5: drawF0NormalDistribution

import org.apache.commons.math3.analysis.function.Gaussian; //导入依赖的package包/类
/**
     * drawF0NormalDistribution
     * 
     * @param parent
     * @param instance 
     */
    public static void drawF0NormalDistribution(Window parent, VoiceStressInstance instance) {
        // create gaussian function
        Gaussian gaussian = new Gaussian(instance.getMean(), instance.getStd());

        // number of values
        int numValues = Config.plotNumValues;
        
        // create x array
        double[] x = new double[numValues];
        
        // calculate x values
        for(int i = 0; i < numValues; i++) {
            x[i] = (((double)i / (double)numValues) * Config.plotXMax);
        }

        // create y array
        double[] y = new double[numValues];

        // calculate y values
        for(int i = 0; i < y.length; i++) {
            y[i] = gaussian.value(x[i]);
        }

        // plot
        Plot2DPanel plot = new Plot2DPanel();
//        plot.setLegendOrientation("EAST");
//        plot.addLegend("Rozkład normanlny tonu fundamentalnego");
        plot.addLinePlot("Rozkład normanlny tonu fundamentalnego", x, y);
        plot.setAxisLabel(0, "Częstotliwość [Hz]");
        plot.setAxisLabel(1, "Rozkład");

        // window
        JDialog window = new JDialog(parent, "Ton Podstawowy");
        window.setSize(600, 600);
        window.setContentPane(plot);
        window.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        window.setLocationRelativeTo(parent);
        window.setVisible(true);
    }
 
开发者ID:andrzejtrzaska,项目名称:VoiceStressAnalysis,代码行数:46,代码来源:PlotUtil.java


示例6: drawNormalDistribution

import org.apache.commons.math3.analysis.function.Gaussian; //导入依赖的package包/类
/**
     * drawNormalDistribution
     * 
     * @param parent
     * @param mean
     * @param std
     */
    public static void drawNormalDistribution(Window parent, double mean, double std) {
        // create gaussian function
        Gaussian gaussian = new Gaussian(mean, std);

        // number of values
        int numValues = Config.plotNumValues;
        
        // create x array
        double[] x = new double[numValues];
        
        // calculate x values
        for(int i = 0; i < numValues; i++) {
            x[i] = (((double)i / (double)numValues) * Config.plotXMax);
        }

        // create y array
        double[] y = new double[numValues];

        // calculate y values
        for(int i = 0; i < y.length; i++) {
            y[i] = gaussian.value(x[i]);
        }

        // plot
        Plot2DPanel plot = new Plot2DPanel();
//        plot.setLegendOrientation("EAST");
//        plot.addLegend("Rozkład normanlny tonu fundamentalnego");
        plot.addLinePlot("Rozkład normanlny", x, y);
        plot.setAxisLabel(0, "Częstotliwość [Hz]");
        plot.setAxisLabel(1, "Rozkład");

        // window
        JDialog window = new JDialog(parent, "Rozkład normanlny");
        window.setSize(600, 600);
        window.setContentPane(plot);
        window.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        window.setLocationRelativeTo(parent);
        window.setVisible(true);
    }
 
开发者ID:andrzejtrzaska,项目名称:VoiceStressAnalysis,代码行数:47,代码来源:PlotUtil.java


示例7: gaussianWindow

import org.apache.commons.math3.analysis.function.Gaussian; //导入依赖的package包/类
private static double[] gaussianWindow(int size) {
    double sigma = ((double) size - 1) / 2;
    double[] gaussian = new double[size];
    Gaussian distribution = new Gaussian(((double) size - 1.) / 2.0, sigma);
    for (int i = 0; i < size; i++) {
        gaussian[i] = distribution.value(i);
    }
    return gaussian;
}
 
开发者ID:jadref,项目名称:buffer_bci,代码行数:10,代码来源:Windows.java


示例8: calculatePersonality

import org.apache.commons.math3.analysis.function.Gaussian; //导入依赖的package包/类
/**
 * Calculate the new personality value
 *
 * @param currentPersonality The individual's current personality
 * @param updateType The type of update being applied
 * @param followers The number of followers in the initiation
 * @return The updated personality value
 * @see edu.snu.leader.hidden.personality.StandardUpdateRulePersonalityCalculator#calculatePersonality(edu.snu.leader.hidden.SpatialIndividual, edu.snu.leader.hidden.personality.PersonalityUpdateType, int)
 */
@Override
public float calculatePersonality( SpatialIndividual individual,
        PersonalityUpdateType updateType,
        int followers )
{
    // Do we change the direction?
    DirectionChange next = _directionChanges.peek();
    if( (next != null) && (next.simIndex <= _simState.getSimIndex()) )
    {
        // Save the data
        _direction = next.direction;
        _sigma = next.sigma;
        _gaussian = new Gaussian( 0.0f, _sigma );
        _maxGaussianValue = 1.0f / (_sigma * (float) Math.sqrt( 2.0f * Math.PI ) );
        _LOG.warn( "New direction=["
                + _direction
                + "] for next.simIndex=["
                + next.simIndex
                + "] simStateSimIdx=["
                + _simState.getSimIndex()
                + "] sigma=["
                + _sigma
                + "] maxGaussianValue=["
                + _maxGaussianValue
                + "]" );

        // Pull it off the queue
        _directionChanges.poll();
    }

    // Go ahead and use the superclass implementation
    return super.calculatePersonality( individual, updateType, followers );
}
 
开发者ID:snucsne,项目名称:bio-inspired-leadership,代码行数:43,代码来源:DirectionUpdateRulePersonalityCalculator.java


示例9: update

import org.apache.commons.math3.analysis.function.Gaussian; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
public void update(Network net,
                   double[] features) {
    final long numCalls = numberOfCalls.incrementAndGet() - 1;
    final double currentLearning = learningFactor.value(numCalls);
    final Neuron best = findAndUpdateBestNeuron(net,
                                                features,
                                                currentLearning);

    final int currentNeighbourhood = neighbourhoodSize.value(numCalls);
    // The farther away the neighbour is from the winning neuron, the
    // smaller the learning rate will become.
    final Gaussian neighbourhoodDecay
        = new Gaussian(currentLearning,
                       0,
                       currentNeighbourhood);

    if (currentNeighbourhood > 0) {
        // Initial set of neurons only contains the winning neuron.
        Collection<Neuron> neighbours = new HashSet<Neuron>();
        neighbours.add(best);
        // Winning neuron must be excluded from the neighbours.
        final HashSet<Neuron> exclude = new HashSet<Neuron>();
        exclude.add(best);

        int radius = 1;
        do {
            // Retrieve immediate neighbours of the current set of neurons.
            neighbours = net.getNeighbours(neighbours, exclude);

            // Update all the neighbours.
            for (Neuron n : neighbours) {
                updateNeighbouringNeuron(n, features, neighbourhoodDecay.value(radius));
            }

            // Add the neighbours to the exclude list so that they will
            // not be update more than once per training step.
            exclude.addAll(neighbours);
            ++radius;
        } while (radius <= currentNeighbourhood);
    }
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:45,代码来源:KohonenUpdateAction.java


示例10: update

import org.apache.commons.math3.analysis.function.Gaussian; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
public void update(Network net,
                   double[] features) {
    final long numCalls = numberOfCalls.incrementAndGet();
    final double currentLearning = learningFactor.value(numCalls);
    final Neuron best = findAndUpdateBestNeuron(net,
                                                features,
                                                currentLearning);

    final int currentNeighbourhood = neighbourhoodSize.value(numCalls);
    // The farther away the neighbour is from the winning neuron, the
    // smaller the learning rate will become.
    final Gaussian neighbourhoodDecay
        = new Gaussian(currentLearning,
                       0,
                       1d / currentNeighbourhood);

    if (currentNeighbourhood > 0) {
        // Initial set of neurons only contains the winning neuron.
        Collection<Neuron> neighbours = new HashSet<Neuron>();
        neighbours.add(best);
        // Winning neuron must be excluded from the neighbours.
        final HashSet<Neuron> exclude = new HashSet<Neuron>();
        exclude.add(best);

        int radius = 1;
        do {
            // Retrieve immediate neighbours of the current set of neurons.
            neighbours = net.getNeighbours(neighbours, exclude);

            // Update all the neighbours.
            for (Neuron n : neighbours) {
                updateNeighbouringNeuron(n, features, neighbourhoodDecay.value(radius));
            }

            // Add the neighbours to the exclude list so that they will
            // not be update more than once per training step.
            exclude.addAll(neighbours);
            ++radius;
        } while (radius <= currentNeighbourhood);
    }
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:45,代码来源:KohonenUpdateAction.java


示例11: initialize

import org.apache.commons.math3.analysis.function.Gaussian; //导入依赖的package包/类
/**
 * Initializes the updater
 *
 * @param simState The simulation's state
 * @see edu.snu.leader.hidden.personality.PersonalityCalculator#initialize(edu.snu.leader.hidden.SimulationState)
 */
@Override
public void initialize( SimulationState simState )
{
    _LOG.trace( "Entering initialize( simState )" );

    // Call the superclass implementation
    super.initialize( simState );

    // Get the properties
    _simState = simState;
    Properties props = simState.getProps();

    // Import the preferred directions
    String directionsFileStr = props.getProperty( _DIRECTIONS_FILE_KEY );
    Validate.notEmpty( directionsFileStr,
            "Directions file (key=["
            + _DIRECTIONS_FILE_KEY
            + "]) may not be empty" );
    _LOG.info( "Using directionsFileStr=["
            + directionsFileStr
            + "]" );
    loadDirectionChanges( directionsFileStr );

    // Get the first direction
    DirectionChange first = _directionChanges.peek();
    if( (first != null) && (first.simIndex <= 0) )
    {
        // Save the data
        _direction = first.direction;
        _sigma = first.sigma;
        _gaussian = new Gaussian( 0.0f, _sigma );
        _maxGaussianValue = 1.0f / (_sigma * (float) Math.sqrt( 2.0f * Math.PI ) );
        _LOG.debug( "Initial direction ["
                + _direction
                + "]" );

        // Pull it off the queue
        _directionChanges.poll();
    }

    // Get the modify winner discount flag
    String modifyWinnerDiscountStr = props.getProperty(
            _MODIFY_WINNER_DISCOUNT_KEY );
    Validate.notEmpty( modifyWinnerDiscountStr,
            "Modify winner discount flag (key=["
                    + _MODIFY_WINNER_DISCOUNT_KEY
                    + "]) may not be empty" );
    _modifyWinnerDiscount = Boolean.parseBoolean( modifyWinnerDiscountStr );
    _LOG.info( "Using _modifyWinnerDiscount=["
            + _modifyWinnerDiscount
            + "]" );

    // Get the modify winner reward flag
    String modifyWinnerRewardStr = props.getProperty(
            _MODIFY_WINNER_REWARD_KEY );
    Validate.notEmpty( modifyWinnerRewardStr,
            "Modify winner discount flag (key=["
                    + _MODIFY_WINNER_REWARD_KEY
                    + "]) may not be empty" );
    _modifyWinnerReward = Boolean.parseBoolean( modifyWinnerRewardStr );
    _LOG.info( "Using _modifyWinnerReward=["
            + _modifyWinnerReward
            + "]" );

    _LOG.trace( "Leaving initialize( simState )" );
}
 
开发者ID:snucsne,项目名称:bio-inspired-leadership,代码行数:73,代码来源:DirectionUpdateRulePersonalityCalculator.java


示例12: initialize

import org.apache.commons.math3.analysis.function.Gaussian; //导入依赖的package包/类
/**
 * Initializes the updater
 *
 * @param simState The simulation's state
 * @see edu.snu.leader.hidden.personality.PersonalityCalculator#initialize(edu.snu.leader.hidden.SimulationState)
 */
@Override
public void initialize( SimulationState simState )
{
    _LOG.trace( "Entering initialize( simState )" );

    // Save the simulation state
    _simState = simState;
    
    // Get the properties
    Properties props = simState.getProps();

    // Get the discount value
    _discount = MiscUtils.loadNonEmptyFloatProperty( props,
            _DISCOUNT_KEY,
            "Trait value discount" );
    _LOG.info( "Using _discount=[" + _discount + "]" );

    // Get the discount value
    _correlatedDiscount = MiscUtils.loadNonEmptyFloatProperty( props,
            _CORRELATED_DISCOUNT_KEY,
            "Correlated trait value discount" );
    _LOG.info( "Using _correlatedDiscount=[" + _correlatedDiscount + "]" );

    // Get the min trait value
    _minTraitValue = MiscUtils.loadNonEmptyFloatProperty( props,
            _MIN_TRAIT_VALUE_KEY,
            "Minimum trait value" );
    _LOG.info( "Using _minTraitValue=[" + _minTraitValue + "]" );

    // Get the min trait value
    _maxTraitValue = MiscUtils.loadNonEmptyFloatProperty( props,
            _MAX_TRAIT_VALUE_KEY,
            "Maximum trait value" );
    _LOG.info( "Using _maxTraitValue=[" + _maxTraitValue + "]" );

    // Create a gaussian for computing changes to discount
    _gaussian = new Gaussian( 0.0f, _sigma );
    _maxGaussianValue = 1.0f / (_sigma * (float) Math.sqrt( 2.0f * Math.PI ) );

    _LOG.trace( "Leaving initialize( simState )" );
}
 
开发者ID:snucsne,项目名称:bio-inspired-leadership,代码行数:48,代码来源:CorrelatedTraitsPersonalityCalculator.java


示例13: findSupportPoints

import org.apache.commons.math3.analysis.function.Gaussian; //导入依赖的package包/类
public void findSupportPoints() {
		
		supportPoints.clear();

		supportMax = 0;
		
//		Map<Line, Double> totalLineSupport = new HashedMap();
		
		double distSigma = 0.2;
		Gaussian distanceG = new Gaussian ( 0, distSigma), angleG = new Gaussian(0, 0.3);
		
		for (Line l : gis.allLines()) {
			double length = l.length();
			int noPoints = (int) Math.max ( 2, length / 0.1 );
			
			for ( int n = 0; n <= noPoints; n ++ ) {
				
				SupportPoint sp = new SupportPoint( l, l.fromPPram(n/ (double)noPoints) );
				
				sp.support = 0;//Double.MAX_VALUE;
				
				for (Line nearL : slice.getNear(sp.pt, distSigma * 3)) {
					
					double angle = nearL.absAngle(sp.line);
					
					double dist = nearL.distance(sp.pt, true);//Math.min  (sp.pt.distance(line.start), sp.pt.distance(line.end)) ;
					
					sp.support += distanceG.value(dist) * angleG.value(angle) * nearL.length();
				}

				supportPoints.add ( sp );

			}
		}
		
		foundLines = null;

		repaint();
	}
 
开发者ID:twak,项目名称:chordatlas,代码行数:40,代码来源:Slice.java



注:本文中的org.apache.commons.math3.analysis.function.Gaussian类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ProjectManagerListener类代码示例发布时间:2022-05-22
下一篇:
Java DescribeKeyPairsRequest类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap