Difference between revisions of "Documentation/How Tos/Calc: PROB function"

From Apache OpenOffice Wiki
Jump to: navigation, search
m (Example:)
m
 
(11 intermediate revisions by 6 users not shown)
Line 1: Line 1:
__NOTOC__
+
{{DISPLAYTITLE:PROB function}}
 +
{{Documentation/CalcFunc StatisticalTOC
 +
|ShowPrevNext=block
 +
|PrevPage=Documentation/How_Tos/Calc:_POISSON_function
 +
|NextPage=Documentation/How_Tos/Calc:_STANDARDIZE_function
 +
}}__NOTOC__
  
 
== PROB ==
 
== PROB ==
Line 9: Line 14:
 
: <tt>'''values'''</tt> is a range or array of numbers (possibly unordered).
 
: <tt>'''values'''</tt> is a range or array of numbers (possibly unordered).
  
: <tt>'''probabilities'''</tt> is a range or array of numbers of the same size as <tt>'''values'''</tt>, indicating the corresponding probability (>0 and <=1) of each value in <tt>'''values'''</tt> occurring. The numbers in <tt>'''probabilities'''</tt> must sum to 1 exactly.
+
: <tt>'''probabilities'''</tt> is a range or array of numbers of the same size as <tt>'''values'''</tt>, indicating the corresponding probability (>0 and <=1) that each value in <tt>'''values'''</tt> will occur. The numbers in <tt>'''probabilities'''</tt> must sum to 1 exactly.
  
 
: <tt>'''PROB'''</tt> finds all <tt>'''values'''</tt> which are between <tt>'''start'''</tt> and <tt>'''end'''</tt> inclusive and returns the sum of their corresponding <tt>'''probabilities'''</tt>.
 
: <tt>'''PROB'''</tt> finds all <tt>'''values'''</tt> which are between <tt>'''start'''</tt> and <tt>'''end'''</tt> inclusive and returns the sum of their corresponding <tt>'''probabilities'''</tt>.
  
 
:  <tt>'''end'''</tt> may be omitted, in which case <tt>'''PROB'''</tt> returns the probability corresponding to <tt>'''start'''</tt> (or <tt>'''0'''</tt> if <tt>'''start'''</tt> is not present in <tt>'''values'''</tt>).
 
:  <tt>'''end'''</tt> may be omitted, in which case <tt>'''PROB'''</tt> returns the probability corresponding to <tt>'''start'''</tt> (or <tt>'''0'''</tt> if <tt>'''start'''</tt> is not present in <tt>'''values'''</tt>).
 +
 +
 +
: Advanced topic: <tt>'''PROB'''</tt> evaluates the <tt>'''values'''</tt> and <tt>'''probabilities'''</tt> parameters as [[Documentation/How_Tos/Using_Arrays|array formulas]] - see the examples.
  
 
=== Example: ===
 
=== Example: ===
Line 25: Line 33:
 
: returns <tt>'''0.4'''</tt>, the probability for <tt>'''4'''</tt>.
 
: returns <tt>'''0.4'''</tt>, the probability for <tt>'''4'''</tt>.
  
=== See also: ===
+
 
[[Documentation/How_Tos/Calc: Statistical functions|'''Statistical functions''']]
+
Evaluation as an * [[Documentation/How_Tos/Using_Arrays|array formula]]:
 +
 
 +
<tt>'''PROB(A1:A2*2; B1:B2; 2)'''</tt>
 +
: where cells A1, A2 contain 1, 4 and cells B1, B2 contain 0.3, 0.7, returns <tt>'''0.3'''</tt>. <tt>'''PROB'''</tt> forces evaluation of <tt>'''values'''</tt> as an array formula, so that <tt>'''A1:A2*2'''</tt> yields the array {2 | 8}. Thus, <tt>'''PROB({2 | 8}; B1:B2; 2)'''</tt> is actually evaluated to give the result.
 +
 
 +
<tt>'''PROB(A1:A2; B1:B2/100; 4)'''</tt>
 +
: where cells A1, A2 contain 1, 4 and cells B1, B2 contain 30, 70, returns <tt>'''0.7'''</tt>. <tt>'''PROB'''</tt> forces evaluation of <tt>'''probabilities'''</tt> as an array formula, so that <tt>'''B1:B2/100'''</tt> yields the array {0.3 | 0.7}. Cells B1 and B2 effectively contain percentages here.
 +
 
 +
=== Issues: ===
 +
*If <tt>'''start'''</tt> is given as a range (eg D4:D5) and the formula entered in scalar (non-array) mode then the top left value of the range appears to be evaluated, rather than the intersection of the range and the formula cell row/column. This is a minor issue which is recorded in {{bug|88967}}.
 +
 
 +
{{SeeAlso|EN|
 +
* [[Documentation/How_Tos/Calc: Statistical functions|Statistical functions]]
 +
* [[Documentation/How_Tos/Using_Arrays|Using Arrays]]
 +
* [[Documentation/How_Tos/Calc: Functions listed alphabetically|Functions listed alphabetically]]
 +
* [[Documentation/How_Tos/Calc: Functions listed by category|Functions listed by category]]}}
 +
[[Category: Documentation/Reference/Calc/Statistical functions]]

Latest revision as of 14:28, 2 February 2024



PROB

Returns a result from a list of probabilities.

Syntax:

PROB(values; probabilities; start; end)

values is a range or array of numbers (possibly unordered).
probabilities is a range or array of numbers of the same size as values, indicating the corresponding probability (>0 and <=1) that each value in values will occur. The numbers in probabilities must sum to 1 exactly.
PROB finds all values which are between start and end inclusive and returns the sum of their corresponding probabilities.
end may be omitted, in which case PROB returns the probability corresponding to start (or 0 if start is not present in values).


Advanced topic: PROB evaluates the values and probabilities parameters as array formulas - see the examples.

Example:

PROB({3; 4; 5; 6}; {0.2; 0.4; 0.3; 0.1}; 4; 6)

returns 0.8, the sum of the probabilities for 4, 5 and 6.

PROB({2.2; 5; 1}; {0.5; 0.3; 0.2}; 0; 3)

returns 0.7, the sum of the probabilities for 1 and 2.2.

PROB({3; 4; 5; 6}; {0.2; 0.4; 0.3; 0.1}; 4)

returns 0.4, the probability for 4.


Evaluation as an * array formula:

PROB(A1:A2*2; B1:B2; 2)

where cells A1, A2 contain 1, 4 and cells B1, B2 contain 0.3, 0.7, returns 0.3. PROB forces evaluation of values as an array formula, so that A1:A2*2 yields the array {2 | 8}. Thus, PROB({2 | 8}; B1:B2; 2) is actually evaluated to give the result.

PROB(A1:A2; B1:B2/100; 4)

where cells A1, A2 contain 1, 4 and cells B1, B2 contain 30, 70, returns 0.7. PROB forces evaluation of probabilities as an array formula, so that B1:B2/100 yields the array {0.3 | 0.7}. Cells B1 and B2 effectively contain percentages here.

Issues:

  • If start is given as a range (eg D4:D5) and the formula entered in scalar (non-array) mode then the top left value of the range appears to be evaluated, rather than the intersection of the range and the formula cell row/column. This is a minor issue which is recorded in Issue 88967 .



See Also
Retrieved from "https://wiki.openoffice.org/w/index.php?title=Documentation/How_Tos/Calc:_PROB_function&oldid=260065"
Views
Personal tools
Navigation
Tools