001/*
002 * Copyright (c) 2015-2020, Oracle and/or its affiliates. All rights reserved.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.tribuo;
018
019import java.io.Serializable;
020import java.util.SplittableRandom;
021
022/**
023 * A VariableInfo subclass contains information about a feature and
024 * its observed values.
025 */
026public interface VariableInfo extends Serializable, Cloneable {
027    /**
028     * The name of this feature.
029     * @return The feature name.
030     */
031    public String getName();
032
033    /**
034     * The occurrence count of this feature.
035     * @return The occurrence count.
036     */
037    public int getCount();
038
039    /**
040     * Generates a VariableIDInfo subclass which represents the same feature.
041     * @param id The id number.
042     * @return A VariableInfo with the same information, plus the id.
043     */
044    public VariableIDInfo makeIDInfo(int id);
045
046    /**
047     * Rename generates a fresh VariableInfo with the new name.
048     *
049     * The name forms part of the hashcode so it's immutable in the object.
050     * @param name The new name.
051     * @return A VariableInfo subclass with the new name.
052     */
053    public VariableInfo rename(String name);
054
055    /**
056     * Sample a value uniformly from the range of this variable.
057     *
058     * @param rng The rng to use.
059     * @return A sample from this variable.
060     */
061    public double uniformSample(SplittableRandom rng);
062
063    /**
064     * Returns a copy of this variable info.
065     * @return A copy.
066     */
067    public VariableInfo copy();
068}