Information about Variable

For the kinds of predefined templates used in Wikipedia, see .
In computer science and mathematics, a variable (IPA pronunciation: [ˈvæɹiəbl]) (sometimes called a pronumeral) is a symbolic representation denoting a quantity or expression. In mathematics, a variable often represents an "unknown" quantity that has the potential to change; in computer science, it represents a place where a quantity can be stored. Variables are often contrasted with constants, which are known and unchanging.

The term has a similar meaning in the physical sciences and engineering: a variable is a quantity whose value may vary over the course of an experiment (including simulations), across samples, or during the operation of a system. Variables are generally distinct from parameters, although what is a variable in one context may be a parameter in another. For more on this distinction, see the article on "parameter".

In applied statistics, a variable is a measurable factor, characteristic, or attribute of an individual or a system—in other words, something that might be expected to vary over time or between individuals. Random variables are an idealisation of this in mathematical statistics, where they are defined as measurable functions from a probability space to a measurable space.

History

commonly represents an unknown variable. Even though any letter can be used, is the most common choice. This usage can be traced back to the Arabic word šay' شيء = “thing”, which in translated algebra texts and similar was taken into Old Spanish with the pronunciation “šei”, which was written xei, which was soon habitually abbreviated to . (The Spanish pronunciation of “x” has changed since.) But some sources say that this is an abbreviation of Latin causa which was a translation of Arabic شيء. That started the habit of using letters to represent quantities in algebra. In mathematics, an “italicized x” () is often used to avoid potential confusion with the multiplication symbol. By extension beyond mathematics, “X” has come to represent a generic placeholder variable whose value is unknown or secret, as in project X or mister X.

General overview

Variables are used in open sentences. For instance, in the formula x + 1 = 5, x is a variable which represents an "unknown" number. Variables are often represented by letters of the Roman alphabet, but are also represented by letters of other alphabets, such as the Greek alphabet, as well as various other symbols. In this sense, variables are used as a "fill-in-the-blank" within many fields (mathematics, linguistics, etc.)

In applied statistics

In statistics, variables refer to measurable attributes, as these typically vary over time or between individuals. Variables can be discrete (taking values from a finite or countable set), continuous (having a continuous distribution function), or neither. Temperature is a continuous variable, while the number of legs of an animal is a discrete variable. This concept of a variable is widely used in the natural, medical and social sciences.

In causal models, a distinction is made between "independent variables" and "dependent variables", the latter being expected to vary in value in response to changes in the former. In other words, an independent variable is presumed to potentially affect a dependent one. In experiments, independent variables include factors that can be altered or chosen by the researcher independent of other factors.

For example, in an experiment to test whether or not the boiling point of water changes with altitude, the altitude is under direct control and is the independent variable, and the boiling point is presumed to depend upon it and is therefore the dependent variable. The collection of results from an experiment, or information to be used to draw conclusions, is known as data. It is often important to consider which variables to allow for, or to directly control or eliminate, in the design of experiments.

While independent variables can refer to quantities and qualities that are under experimental control, they can also include extraneous factors that influence results in a confusing or undesired manner.

In general, if strongly confounding variables exist that can substantially affect the result, then this makes it more difficult to interpret the results. For example, a study into the incidence of cancer with age will also have to take into account variables such as income (poorer people may have less healthy lives), location (some cancers vary depending on diet and sunlight), stress and lifestyle issues (cancer may be related to these more than age), and so on. Failure to at least consider these factors can lead to grossly inaccurate deductions. For this reason, controlling unwanted variables is important in research.

See also:  and

In mathematics

Variables are useful in mathematics because they allow instructions to be specified in a general way. If one were forced to use actual values, then the instructions would only apply in a more narrow set of situations. For example:
:Specify a mathematical definition for finding the number twice that of ANY number: double(x) = x + x.


:Now, all we need to do to find the double of a number is replace x with any number we want.


:*double(1) = 1 + 1 = 2
:*double(3) = 3 + 3 = 6
:*double(55) = 55 + 55 = 110
:*etc.


In the above example, the variable x is a "placeholder" for any number. One important thing we are assuming is that the value of each occurrence of x is the same—that x does not get a new value between the first x and the second x.

(Note that in computer programming languages without referential transparency, changes such as this can occur. Variables in computer programming are also useful for this reason. The term "variable", as used by programmers, is much more vague than the meaning of "variable" as used by mathematicians.)

In computer programming

Variables in computer programming are very different from variables in mathematics and the apparent similarity is source of much confusion. Variables in most of mathematics (those that are extensional and referentially transparent) are time-independent unknowns, while in programming a variable can associate with different values at different times (as they are intensional).

In computer programming a variable is a special value (also often called a reference) that has the property of being able to be associated with another value (or not). What is variable across time is the association. Obtaining the value associated with a variable is often called dereferencing, and creating or changing the association is called assignment.

Variables are usually named by an identifier, but they can be anonymous, and variables can be associated with other variables.

In the computing context, variable identifiers often consist of alphanumeric strings. These identifiers are then used to refer to values in computer memory. This convention of matching identifiers to values is but one of several alternative programmatic conventions for accessing values in computer memory (see also: reflection (computer science)).

Variable naming conventions

See also:  and


In some programming languages, specific characters (known as sigils) are prefixed or appended to variable identifiers to indicate the variable's type. For example:
  • in BASIC, the suffix $ on a variable name indicates that its value is a string;
  • in Perl, the sigils $, @, %, and & indicate scalar, array, hash, and subroutine variables, respectively.
  • in spreadsheets variables can refer to cells (e.g. $A$2), named ranges, or values in associated source code or functions.

Variables in source code

In computer source code, a variable name is one way to bind a variable to a memory location; the corresponding value is stored as a data object in that location so that the object can be accessed and manipulated later via the variable's name.

Variables in spreadsheets

In a spreadsheet, a cell may contain a formula with references to other cells. Such a cell reference is a kind of variable; its value is the value of the referenced cell (see also: reference (computer science)).

Scope and extent

The scope of a variable describes where in a program's text, the variable may be used, while the extent (or lifetime) describes when in a program's execution a variable has a value. The scope of a variable is actually a property of the name of the variable, and the extent is a property of the variable itself.

A variable name's scope affects its extent.

Scope is a lexical aspect of a variable. Most languages define a specific scope for each variable (as well as any other named entity), which may differ within a given program. The scope of a variable is the portion of the program code for which the variable's name has meaning and for which the variable is said to be "visible". Entrance into that scope typically begins a variable's lifetime and exit from that scope typically ends its lifetime. For instance, a variable with "lexical scope" is meaningful only within a certain block of statements or subroutine. A "global variable", or one with indefinite scope, may be referred to anywhere in the program. It is erroneous to refer to a variable where it is out of scope. Lexical analysis of a program can determine whether variables are used out of scope. In compiled languages, such analysis can be performed statically at compile time.

Extent, on the other hand, is a runtime (dynamic) aspect of a variable. Each binding of a variable to a value can have its own extent at runtime. The extent of the binding is the portion of the program's execution time during which the variable continues to refer to the same value or memory location. A running program may enter and leave a given extent many times, as in the case of a closure.

In portions of code, a variable in scope may never have been given a value, or its value may have been destroyed. Such variables are described as "out of extent" or "unbound". In many languages, it is an error to try to use the value of a variable when it is out of extent. In other languages, doing so may yield unpredictable results. Such a variable may, however, be assigned a new value, which gives it a new extent. By contrast, it is permissible for a variable binding to extend beyond its scope, as occurs in Lisp closures and C static variables. When execution passes back into the variable's scope, the variable may once again be used.

For space efficiency, a memory space needed for a variable may be allocated only when the variable is first used and freed when it is no longer needed. A variable is only needed when it is in scope, but beginning each variable's lifetime when it enters scope may give space to unused variables. To avoid wasting such space, compilers often warn programmers if a variable is declared but not used.

It is considered good programming practice to make the scope of variables as narrow as feasible so that different parts of a program do not accidentally interact with each other by modifying each other's variables. Doing so also prevents action at a distance. Common techniques for doing so are to have different sections of a program use different namespaces, or to make individual variables "private" through either dynamic variable scoping or lexical variable scoping.

Many programming languages employ a reserved value (often named null or nil) to indicate an invalid or uninitialized variable.

Typed and untyped variables

In statically-typed languages such as Java or ML, a variable also has a type, meaning that only values of a given class (or set of classes) can be stored in it. In dynamically-typed languages such as Python, it is values, not variables, which carry type. In Common Lisp, both situations exist simultaneously: a variable is given a type (if undeclared, it is assumed to be T, the universal supertype) which exists at compile time. Values also have types, which can be checked and queried at runtime. See type system.

Typing of variables also allows polymorphisms to be resolved at compile time. However, this is different from the polymorphism used in object-oriented function calls (referred to as virtual functions in C++) which resolves the call based on the value type as opposed to the supertypes the variable is allowed to have.

Variables often store simple data-like integers and literal strings, but some programming languages allow a variable to store values of other datatypes as well. Such languages may also enable functions to be parametric polymorphic. These functions operate like variables to represent data of multiple types. For example, a function named length may determine the length of a list. Such a length function may be parametric polymorphic by including a type variable in its type signature, since the amount of elements in the list is independent of the elements' types.

Parameters

The formal parameters of functions are also referred to as variables. For instance, in this Python code segment,

def addtwo(x): return x + 2

addtwo(5) # yields 7

and its equivalent code segment in Lisp,

(defun addtwo (x) (+ x 2)) (addtwo 5) ; yields 7

the variable named x is a parameter because it is given a value when the function is called. The integer 5 is the argument which gives x its value. In most languages, function parameters have local scope. This specific variable named x can only be referred to within the addtwo function (though of course other functions can also have variables called x).

Memory allocation

The specifics of variable allocation and the representation of their values vary widely, both among programming languages and among implementations of a given language. Many language implementations allocate space for local variables, whose extent lasts for a single function call on the call stack, and whose memory is automatically reclaimed when the function returns. (More generally, in name binding, the name of a variable is bound to the address of some particular block (contiguous sequence) of bytes in memory, and operations on the variable manipulate that block. Referencing is more common for variables whose values have large or unknown sizes when the code is compiled. Such variables reference the location of the value instead of the storing value itself, which is allocated from a pool of memory called the heap.

Bound variables have values. A value, however, is an abstraction, an idea; in implementation, a value is represented by some data object, which is stored somewhere in computer memory. The program, or the runtime environment, must set aside memory for each data object and, since memory is finite, ensure that this memory is yielded for reuse when the object is no longer needed to represent some variable's value.

Objects allocated from the heap must be reclaimed specially when the objects are no longer needed. In a garbage-collected language (such as C#, Java, and Lisp), the runtime environment automatically reclaims objects when extant variables can no longer refer to them. In non-garbage-collected languages, such as C, the program (and thus the programmer) must explicitly allocate memory, and then later free it, to reclaim its memory. Failure to do so leads to memory leaks, in which the heap is depleted as the program runs, risking eventual failure from exhausting available memory.

When a variable refers to a data structure created dynamically, some of its components may be only indirectly accessed through the variable. In such circumstances, garbage collectors (or analogous program features in languages that lack garbage collectors) must deal with a case where only a portion of the memory reachable from the variable needs to be reclaimed.

Constants

A constant variable is a variable whose value cannot be changed once it is initially bound to a value. In other words, constant variables cannot be assigned to. In purely functional programming, all variables are constant, because there is no assignment.

Although a constant value is specified only once, the constant variable can be referenced multiple times in a program. Using a constant instead of specifying a value multiple times in the program can not only simplify code maintenance, but it can also supply a meaningful name for it and consolidate such constant assignments to a standard code location (for example, at the beginning).

Programming languages provide one of two kinds of constant variables:
Static constant or Manifest constant: Languages such as Visual Basic allow assigning a fixed value to static constant which will be known at compile time. Such a constant has the same value each time its program runs. Changing the value is accomplished by changing (and possibly recompiling) the code. E.g.: CONST a = 60.


Dynamic constant: Languages such as C++ and Java allow initializing a dynamic constant with a value that is computed at runtime. Thus, unlike static constants, the values of dynamic constants cannot be determined at compile time. E.g.: final int a = b + 20;.


For variables which are references, do not confuse constant references with immutable objects. For example, when a non-constant reference references an immutable object, that reference can be changed so that it references a different object, but the object it originally pointed to cannot be changed (i.e. other references that reference it still see the same information).

Conversely, a constant reference may reference a mutable object. In this case, the reference will always reference the same object (the reference cannot be changed); however, the object that the reference references can still be changed (and other references that also reference that object will see the change), as shown in the following example:

final StringBuffer sampleDynamicConstant = new StringBuffer ("InitialValueOfDynamicConstant"); sampleDynamicConstant.append("_AppendedText"); System.out.println(sampleDynamicConstant);

The above code produces the following output:

InitialValueOfDynamicConstant_AppendedText

In languages where a variable can be an object (i.e. C++), such a variable being constant is equivalent to the immutability of that object.

Variable interpolation

Variable interpolation (also variable substitution, variable expansion) is the process of evaluating an expression or string literal containing one or more variables, yielding a result in which the variables are replaced with their corresponding values in memory. It is a specialized instance of concatenation.

For example, the following Perl code:

my $name = "Nancy"; print "$name said Hello World to the crowd of people.";

produces the output:

Nancy said Hello World to the crowd of people.

See also

Computer science, or computing science, is the study of the theoretical foundations of information and computation and their implementation and application in computer systems.
..... Click the link for more information.
Mathematics (colloquially, maths or math) is the body of knowledge centered on such concepts as quantity, structure, space, and change, and also the academic discipline that studies them. Benjamin Peirce called it "the science that draws necessary conclusions".
..... Click the link for more information.
International Phonetic Alphabet

Note: This page may contain IPA phonetic symbols in Unicode.

The International
Phonetic Alphabet
History
Nonstandard symbols
Extended IPA
Naming conventions
IPA for English The
..... Click the link for more information.
Symbols are objects, characters, or other concrete representations of ideas, concepts, or other abstractions. For example, in the United States, Canada and Great Britain, a red octagon is a symbol for the traffic sign meaning "STOP".
..... Click the link for more information.
Quantity is a kind of property which exists as magnitude or multitude. It is among the basic classes of things along with quality, substance, change, and relation. Quantity was first introduced as quantum, an entity having quantity.
..... Click the link for more information.
Change denotes the transition that occurs between one state to another.

Physical

Throughout history, change has been defined by varying points of view. In ancient Greek philosophy, while Herachical position may have an influence on the perception of change.
..... Click the link for more information.
In mathematics and the mathematical sciences, a constant is a fixed, but possibly unspecified, value. This is in contrast to a variable, which is not fixed.

Unspecified constants

The most widely mentioned sort of constant
..... Click the link for more information.
Physical science is an encompassing term for the branches of natural science, and science, that study non-living systems, in contrast to the biological sciences. However, the term "physical" creates an unintended, somewhat arbitrary distinction, since many branches of physical
..... Click the link for more information.
Engineering is the applied science of acquiring and applying knowledge to design, analysis, and/or construction of works for practical purposes. The American Engineers' Council for Professional Development, also known as ECPD,[1] (later ABET [2]
..... Click the link for more information.
Parameters, in the plural form, has recently become popular with non-technical users to mean limits, but this should not be confused with the word's technical meaning.

In mathematics, statistics, and the mathematical sciences, parameters (L: auxiliary measure
..... Click the link for more information.
Parameters, in the plural form, has recently become popular with non-technical users to mean limits, but this should not be confused with the word's technical meaning.

In mathematics, statistics, and the mathematical sciences, parameters (L: auxiliary measure
..... Click the link for more information.
Statistics is a mathematical science pertaining to the collection, analysis, interpretation or explanation, and presentation of data. It is applicable to a wide variety of academic disciplines, from the physical and social sciences to the humanities.
..... Click the link for more information.
A random variable is an abstraction of the intuitive concept of chance into the theoretical domains of mathematics, forming the foundations of probability theory and mathematical statistics.
..... Click the link for more information.
Mathematical statistics uses probability theory and other branches of mathematics to study statistics from a purely mathematical standpoint.

Mathematical statistics is the subject of mathematics that deals with gaining information from data.
..... Click the link for more information.
In mathematics, measurable functions are well-behaved functions between measurable spaces. Functions studied in analysis that are not measurable are generally considered pathological.
..... Click the link for more information.
In probability theory, the definition of the probability space is the foundation of probability theory. It was introduced by Kolmogorov in the 1930s. For an algebraic alternative to Kolmogorov's approach, see algebra of random variables.
..... Click the link for more information.
Algebra is a branch of mathematics concerning the study of structure, relation and quantity. The name is derived from the treatise written by the Arabic[1] mathematician, astronomer, astrologer and geographer,
..... Click the link for more information.

 Spanish, Castilian
}}} 
Writing system: Latin (Spanish variant)
Language codes
ISO 639-1: none
ISO 639-2:
ISO 639-3: —

Spanish (
..... Click the link for more information.
Pronunciation refers to:
  • the way a word or a language is usually spoken;
  • the manner in which someone utters a word.

Introduction

A word can be spoken in different ways by various individuals or groups, depending on many factors, such as:

..... Click the link for more information.
Algebra is a branch of mathematics concerning the study of structure, relation and quantity. The name is derived from the treatise written by the Arabic[1] mathematician, astronomer, astrologer and geographer,
..... Click the link for more information.
In typography, italic type refers to cursive typefaces based on a stylized form of calligraphic handwriting. The influence from calligraphy can be seen in their usual slight slanting to the right.
..... Click the link for more information.
An open sentence is a sentence which contains variables. Unlike an ordinary sentence, which contains constants, open sentences do not express propositions; they are neither true nor false. Hence, the open sentence:

(1) x is a number

Has no truth-value.
..... Click the link for more information.
number is an abstract idea used in counting and measuring. A symbol which represents a number is called a numeral, but in common usage the word number is used for both the idea and the symbol.
..... Click the link for more information.
A letter is a written message from one person to another. The role of letters in communication has changed significantly since the 19th century. Historically, letters were the only reliable means of communication between two persons in different locations.
..... Click the link for more information.
Latin alphabet
Child systems Numerous: see Alphabets derived from the Latin
Sister systems Cyrillic
Coptic
Armenian
Runic/Futhark
Unicode range See Latin characters in Unicode
ISO 15924 Latn

Note
..... Click the link for more information.
ABCs redirects here, for the Alien Big Cats, see British big cats.


An alphabet is a standardized set of letters
..... Click the link for more information.
Greek alphabet
Child systems Gothic
Glagolitic
Cyrillic
Coptic
Old Italic alphabet
Latin alphabet

ISO 15924 Grek

Note: This page may contain IPA phonetic symbols in Unicode.
..... Click the link for more information.
Symbols are objects, characters, or other concrete representations of ideas, concepts, or other abstractions. For example, in the United States, Canada and Great Britain, a red octagon is a symbol for the traffic sign meaning "STOP".
..... Click the link for more information.
discrete if it is characterized by a probability mass function. Thus, the distribution of a random variable X is discrete, and X is then called a discrete random variable, if



as u
..... Click the link for more information.
countable set is a set with the same cardinality (i.e., number of elements) as some subset of the set of natural numbers. The term was originated by Georg Cantor; it stems from the fact that the natural numbers are often called counting numbers.
..... Click the link for more information.


This article is copied from an article on Wikipedia.org - the free encyclopedia created and edited by online user community. The text was not checked or edited by anyone on our staff. Although the vast majority of the wikipedia encyclopedia articles provide accurate and timely information please do not assume the accuracy of any particular article. This article is distributed under the terms of GNU Free Documentation License.
Herod_Archelaus


page counter