| career | drupal | java | mac | mysql | perl | scala | uml | unix  

Commons Math example source code file (

This example Commons Math source code file ( is included in the "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Commons Math tags/keywords

arraylist, arraylist, deprecated, estimatedparameter, estimatedparameter, estimationproblem, list, list, simpleestimationproblem, simpleestimationproblem, util, weightedmeasurement

The Commons Math source code

 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * See the License for the specific language governing permissions and
 * limitations under the License.

package org.apache.commons.math.estimation;

import java.util.ArrayList;
import java.util.List;

 * Simple implementation of the {@link EstimationProblem
 * EstimationProblem} interface for boilerplate data handling.
 * <p>This class only handles parameters and measurements
 * storage and unbound parameters filtering. It does not compute
 * anything by itself. It should either be used with measurements
 * implementation that are smart enough to know about the
 * various parameters in order to compute the partial derivatives
 * appropriately. Since the problem-specific logic is mainly related to
 * the various measurements models, the simplest way to use this class
 * is by extending it and using one internal class extending
 * {@link WeightedMeasurement WeightedMeasurement} for each measurement
 * type. The instances of the internal classes would have access to the
 * various parameters and their current estimate.</p>

 * @version $Revision: 811827 $ $Date: 2009-09-06 11:32:50 -0400 (Sun, 06 Sep 2009) $
 * @since 1.2
 * @deprecated as of 2.0, everything in package org.apache.commons.math.estimation has
 * been deprecated and replaced by package org.apache.commons.math.optimization.general

public class SimpleEstimationProblem implements EstimationProblem {

    /** Estimated parameters. */
    private final List<EstimatedParameter> parameters;

    /** Measurements. */
    private final List<WeightedMeasurement> measurements;

     * Build an empty instance without parameters nor measurements.
    public SimpleEstimationProblem() {
        parameters   = new ArrayList<EstimatedParameter>();
        measurements = new ArrayList<WeightedMeasurement>();

     * Get all the parameters of the problem.
     * @return parameters
    public EstimatedParameter[] getAllParameters() {
        return parameters.toArray(new EstimatedParameter[parameters.size()]);

     * Get the unbound parameters of the problem.
     * @return unbound parameters
    public EstimatedParameter[] getUnboundParameters() {

        // filter the unbound parameters
        List<EstimatedParameter> unbound = new ArrayList(parameters.size());
        for (EstimatedParameter p : parameters) {
            if (! p.isBound()) {

        // convert to an array
        return unbound.toArray(new EstimatedParameter[unbound.size()]);


     * Get the measurements of an estimation problem.
     * @return measurements
    public WeightedMeasurement[] getMeasurements() {
        return measurements.toArray(new WeightedMeasurement[measurements.size()]);

    /** Add a parameter to the problem.
     * @param p parameter to add
    protected void addParameter(EstimatedParameter p) {

     * Add a new measurement to the set.
     * @param m measurement to add
    protected void addMeasurement(WeightedMeasurement m) {


Other Commons Math examples (source code examples)

Here is a short list of links related to this Commons Math source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller


new blog posts


Copyright 1998-2021 Alvin Alexander,
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.