Probabilistic choice: Difference between revisions
m
syntax highlighting fixup automation
(Probabilistic choice in Yabasic) |
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
||
Line 19:
=={{header|Ada}}==
<
with Ada.Text_IO; use Ada.Text_IO;
Line 52:
end if;
end loop;
end Random_Distribution;</
Sample output:
<pre>
Line 72:
{{works with|ALGOL 68G|Any - tested with release [http://sourceforge.net/projects/algol68/files/algol68g/algol68g-1.18.0/algol68g-1.18.0-9h.tiny.el5.centos.fc11.i386.rpm/download 1.18.0-9h.tiny]}}
{{wont work with|ELLA ALGOL 68|Any (with appropriate job cards) - tested with release [http://sourceforge.net/projects/algol68/files/algol68toc/algol68toc-1.8.8d/algol68toc-1.8-8d.fc9.i386.rpm/download 1.8-8d] - due to extensive use of FORMATted transput}}
<
MODE LREAL = LONG REAL;
Line 143:
FOR i FROM LWB items TO UPB items DO printf(($f(real repr)" "$, prob count OF items[i]/trials)) OD;
printf($l$)
)</
Sample output:
<pre>
Line 155:
AppleScript does have a <tt>random number</tt> command, but this is located in the StandardAdditions OSAX and invoking it a million times can take quite a while. Since Mac OS X 10.11, it's been possible to use the randomising features of the system's "GameplayKit" framework, which are faster to access.
<
use framework "Foundation"
use framework "GameplayKit"
Line 216:
end task
task()</
{{output}}
<
{|item|:aleph, probability:0.2, actual:0.20033}, ¬
{|item|:beth, probability:0.166666666667, actual:0.166744}, ¬
Line 228:
{|item|:zayin, probability:0.090909090909, actual:0.090721}, ¬
{|item|:heth, probability:0.063455988456, actual:0.063817} ¬
}"</
=={{header|Arturo}}==
<
probabilities: #[
aleph: to :rational [1 5]
Line 281:
pad to :string to :floating s2 10
pad to :string s1 10
]</
{{out}}
Line 300:
=={{header|AutoHotkey}}==
contributed by Laszlo on the ahk [http://www.autohotkey.com/forum/post-276279.html#276279 forum]
<
s2 := "beth", p2 := 1/6.0
s3 := "gimel", p3 := 1/7.0
Line 338:
heth 0.063456 0.063342
---------------------------
*/</
=={{header|AWK}}==
<
BEGIN {
Line 414:
counts[sym] = 0;
}
</syntaxhighlight>
Example output:
Line 435:
=={{header|BASIC256}}==
{{trans|FreeBASIC}}
<
dim actual(8) fill 0 ## all zero by default
dim probs = {1/5.0, 1/6.0, 1/7.0, 1/8.0, 1/9.0, 1/10.0, 1/11.0, 0}
Line 485:
print " ", "--------", "--------"
print " ", ljust(sumActual,8,"0"), "1.000000"
end</
=={{header|BBC BASIC}}==
<
item$() = "aleph","beth","gimel","daleth","he","waw","zayin","heth"
prob() = 1/5.0, 1/6.0, 1/7.0, 1/8.0, 1/9.0, 1/10.0, 1/11.0, 1759/27720
Line 506:
FOR i% = 0 TO DIM(item$(),1)
PRINT item$(i%), cnt%(i%)/1E6, prob(i%)
NEXT</
'''Output:'''
<pre>
Line 521:
=={{header|C}}==
<
#include <stdlib.h>
Line 554:
return 0;
}</
aleph 199928 19.9928% 20.0000%
beth 166489 16.6489% 16.6667%
Line 562:
waw 99935 9.9935% 10.0000%
zayin 91001 9.1001% 9.0909%
heth 63330 6.3330% 6.3456%</
=={{header|C sharp|C#}}==
Line 568:
{{trans|Java}}
<
using System;
Line 640:
}
}
</syntaxhighlight>
Output:
Line 650:
=={{header|C++}}==
<
#include <iostream>
#include <vector>
Line 701:
}
return 0 ;
}</
Output:
<PRE>letter frequency attained frequency expected
Line 719:
It uses the language built-in (frequencies) to count the number of occurrences of each distinct name. Note that while we actually generate a sequence of num-trials random samples, the sequence is lazily generated and lazily consumed. This means that the program will scale to an arbitrarily-large num-trials with no ill effects, by throwing away elements it's already processed.
<
(reduce
(fn [acc n] (conj acc (+ (or (last acc) 0) n)))
Line 740:
(doseq [[idx exp] expected]
(println "Expected number of" (*names* idx) "was"
(* num-trials exp) "and actually got" (actual idx))))</
<pre>Expected number of aleph was 200000.0 and actually got 199300
Line 754:
This is a straightforward, if a little verbose implementation based upon the Perl one.
<
(beth 1/6)
(gimel 1/7)
Line 799:
WAW 0.100068 0.1
ZAYIN 0.090458 0.09090909
HETH 0.063481 0.06345599</
=={{header|D}}==
===Basic Version===
<
import std.stdio, std.random, std.string, std.range;
Line 817:
foreach (name, p, co; zip(items, pr, counts[]))
writefln("%-7s %.8f %.8f", name, p, co / nTrials);
}</
{{out}}
<pre>Item Target prob Attained prob
Line 830:
===A Faster Version===
<
import std.stdio, std.random, std.algorithm, std.range;
Line 850:
foreach (name, p, co; zip(items, pr, counts[]))
writefln("%-7s %.8f %.8f", name, p, co / nTrials);
}</
=={{header|E}}==
Line 858:
It is rather verbose, due to using the tree rather than a linear search, and having code to print the tree (which was used to debug it).
<
First, the algorithm:
<
def leaf(value) {
return def leaf {
Line 916:
}
}
}</
Then the test setup:
<
"aleph" => 1/5,
"beth" => 1/6.0,
Line 941:
for item in probTable.domain() {
stdout.print(item, "\t", timesFound[item] / trials, "\t", probTable[item], "\n")
}</
=={{header|Elixir}}==
{{trans|Erlang}}
<
@tries 1000000
@probs [aleph: 1/5,
Line 971:
end
Probabilistic.test</
{{out}}
Line 990:
The optimized version of Java.
<
-module(probabilistic_choice).
Line 1,022:
get_choice(T,Ran - Prob)
end.
</syntaxhighlight>
Output:
Line 1,038:
=={{header|ERRE}}==
<
DIM ITEM$[7],PROB[7],CNT[7]
Line 1,072:
END FOR
END IF
END PROGRAM</
Output:
Line 1,091:
=={{header|Euphoria}}==
{{trans|PureBasic}}
<
constant times = 1e6
atom d,e
Line 1,123:
printf(1,"%-7s should be %f is %f | Deviatation %6.3f%%\n",
{Mapps[j][1],Mapps[j][2],d,(1-Mapps[j][2]/d)*100})
end for</
Output:
Line 1,138:
=={{header|Factor}}==
<
math.statistics prettyprint quotations sequences sorting formatting ;
IN: rosettacode.proba
Line 1,174:
: example ( # data -- )
[ case-probas generate-normalized ]
[ summarize ] bi ; inline</
In a REPL:
<syntaxhighlight lang="text">USE: rosettacode.proba
1000000 data example</
outputs
<syntaxhighlight lang="text"> Key Value expected
heth: 0.063469 0.063456
waw: 0.100226 0.100000
Line 1,188:
he: 0.110562 0.111111
aleph: 0.199868 0.200000
gimel: 0.142961 0.142857</
=={{header|Fermat}}==
<
trials:=1000000;
Line 1,240:
!!('The various probabilities add up to ',Sigma<i=1,8>[count[i]/trials]); {check if our trials add to 1}
</syntaxhighlight>
{{out}}<pre>
aleph 199939 / 1000000 differs from 1 / 5 by -61 / 1000000 or about one part in 16393
Line 1,262:
=={{header|Forth}}==
<
\ common factors of desired probabilities (1/5 .. 1/11)
Line 1,305:
f- fabs fs. ;
: .results .header 8 0 do i .result loop ;</
<pre>
Line 1,324:
=={{header|Fortran}}==
{{works with|Fortran|90 and later}}
<
IMPLICIT NONE
Line 1,356:
WRITE(*, "(A,8F10.6)") "Attained Probability:", REAL(probcount) / REAL(trials)
ENDPROGRAM PROBS</
Sample Output:
<pre>
Line 1,365:
=={{header|FreeBASIC}}==
<
Dim letters (0 To 7) As String = {"aleph", "beth", "gimel", "daleth", "he", "waw", "zayin", "heth"}
Line 1,423:
Print
Print "Press any key to quit"
Sleep</
{{out}}
Line 1,442:
=={{header|Go}}==
<
import (
Line 1,504:
}
fmt.Printf("Totals %8.6f %8.6f\n", totalTarget, totalGenerated)
}</
Output:
<pre>
Line 1,520:
=={{header|Haskell}}==
<
dataBinCounts :: [Float] -> [Float] -> [Int]
Line 1,545:
["aleph", "beth", "gimel", "daleth", "he", "waw", "zayin", "heth"]
expected
actual</
{{Out}}
Sample
Line 1,559:
=={{header|HicEst}}==
<
expected = 1 / ($ + 4)
Line 1,575:
outcome = outcome / trials
DLG(Text=expected, Text=outcome, Y=0) </
Exported from the spreadsheet-like DLG function:
<pre>0.2 0.199908
Line 1,588:
=={{header|Icon}} and {{header|Unicon}}==
<syntaxhighlight lang="icon">
record Item(value, probability)
Line 1,639:
left(count(sample, item.value)/*sample, 6))
end
</syntaxhighlight>
Output:
Line 1,654:
=={{header|J}}==
<syntaxhighlight lang="j">
main=: verb define
hdr=. ' target actual '
Line 1,671:
da (distribution of actual values among partitions)
pa (actual proportions)
)</
Example use:
<
target actual
aleph 0.200000 0.200344
Line 1,682:
waw 0.100000 0.099751
zayin 0.090909 0.091121
heth 0.063456 0.063527</
Note that there is no rounding error in summing the proportions, as they are represented as rational numbers, not floating-point approximations.
<
pt
1r5 1r6 1r7 1r8 1r9 1r10 1r11 1759r27720
+/pt
1</
=={{header|Java}}==
{{trans|C}}
<
static long TRIALS= 1000000;
Line 1,758:
}
}</
Output:
<pre>Trials: 1000000
Line 1,765:
Attained prob.: 0.199615 0.167517 0.142612 0.125211 0.110970 0.099614 0.091002 0.063459 </pre>
{{works with|Java|1.5+}}
<
public class Prob {
Line 1,816:
return null;
}
}</
Output:
<pre>Target probabliities: {ALEPH=0.2, BETH=0.16666666666666666, GIMEL=0.14285714285714285, DALETH=0.125, HE=0.1111111111111111, WAW=0.1, ZAYIN=0.09090909090909091, HETH=0.06345598845598846}
Line 1,824:
===ES5===
Fortunately, iterating over properties added to an object maintains the insertion order.
<
aleph: 1/5.0,
beth: 1/6.0,
Line 1,855:
for (var name in probabilities)
// using WSH
WScript.Echo(name + "\t" + probabilities[name] + "\t" + randomly[name]/iterations);</
output:
<pre>aleph 0.2 0.200597
Line 1,869:
By functional composition:
{{Trans|Haskell}}
<
'use strict';
Line 1,974:
.map(unwords)
.join('\n');
})();</
{{Out}}
Sample:
Line 1,989:
=={{header|Julia}}==
I made the solution to this task more difficult than I had anticipated by using the Hebrew characters (rather than their anglicised names) as labels for the sampled collection of objects. In doing so, I encountered an interesting subtlety of bidirectional text in Unicode. Namely, that strong right-to-left characters, such as those of Hebrew, override the directionality of European digits, which have weak directionality. Because of this property of Unicode, my table of items and yields had its lines of data interpreted as if it were entirely Hebrew and output in reverse order (from my English speaking perspective). I was able to get the table to display as I liked on my terminal by preceding the the Hebrew characters by the Unicode RLI (right-to-left isolate) control character (<tt>U+2067</tt>). However, when I pasted this output into this Rosetta Code entry, the display reverted to the "backwards" version. Rather than continue the struggle, trying to force this entry to display as it does on my terminal, I created an alternative version of the table. This "Displayable Here" table adds "yields" to to each line, and this strong left-to-right text makes the whole line display as left-to-right (without the need for a RLI characer).
<
p = [1/i for i in 5:11]
Line 2,020:
plab[i], accum[i], p[i], r[i]))
end
</syntaxhighlight>
{{out}}
Line 2,056:
=={{header|Kotlin}}==
{{trans|FreeBASIC}}
<
fun main(args: Array<String>) {
Line 2,093:
println("\t-------- --------")
println("\t${"%8.6f".format(sumActual)} 1.000000")
}</
{{out}}
Line 2,112:
=={{header|Liberty BASIC}}==
<syntaxhighlight lang="lb">
names$="aleph beth gimel daleth he waw zayin heth"
dim sum(8)
Line 2,137:
print word$(names$, i), using( "#.#####", counter(i) /N), using( "#.#####", 1/(i+4))
next
</syntaxhighlight>
=={{header|Lua}}==
<
items["aleph"] = 1/5.0
items["beth"] = 1/6.0
Line 2,173:
for item, _ in pairs( items ) do
print( item, samples[item]/num_trials, items[item] )
end</
Output
<pre>gimel 0.142606 0.14285714285714
Line 2,186:
=={{header|Mathematica}}/{{header|Wolfram Language}}==
Built-in function can already do a weighted random choosing. Example for making a million random choices would be:
<
data=RandomChoice[choices[[All,2]]->choices[[All,1]],10^6];</
To compare the data we use the following code to make a table:
<
gives back (item, attained prob., target prob.):
<pre>aleph 0.200036 0.2
Line 2,202:
=={{header|MATLAB}}==
{{works with|MATLAB|with Statistics Toolbox}}
<
choices = {'aleph' 'beth' 'gimel' 'daleth' 'he' 'waw' 'zayin' 'heth'};
w = [1/5 1/6 1/7 1/8 1/9 1/10 1/11 1759/27720];
Line 2,212:
choices{k}, T(k, 2), T(k, 3), 100*w(k))
end
end</
{{out}}
<pre>Value Count Percent Goal
Line 2,224:
heth 63171 6.32% 6.35%</pre>
{{works with|MATLAB|without toolboxes}}
<
choices = {'aleph' 'beth' 'gimel' 'daleth' 'he' 'waw' 'zayin' 'heth'};
w = [1/5 1/6 1/7 1/8 1/9 1/10 1/11 1759/27720];
Line 2,240:
choices{k}, results(k), 100*results(k)/nSamp, 100*w(k))
end
end</
{{out}}
<pre>Value Count Percent Goal
Line 2,253:
=={{header|Nim}}==
<
var start = cpuTime()
Line 2,286:
echo "====== ======== ======== "
echo &"Total: {s2:^8.2f} {s1:^8.2f}"
echo &"\nExecution time: {cpuTime()-start:.2f} s"</
{{out}}
Line 2,306:
=={{header|OCaml}}==
<
"Aleph", 1.0 /. 5.0;
"Beth", 1.0 /. 6.0;
Line 2,335:
let d = Hashtbl.find h v in
Printf.printf "%s \t %f %f\n" v p (float d /. float n)
) p</
Output:
Line 2,348:
=={{header|PARI/GP}}==
<
my(v=[5544,10164,14124,17589,20669,23441,25961,27720],u=vector(8),e);
for(i=1,1e6,
Line 2,361:
print("Diff: ",u-e);
print("StDev: ",vector(8,i,sqrt(abs(u[i]-v[i])/e[i])));
};</
=={{header|Perl}}==
<
use constant TRIALS => 1e6;
Line 2,401:
$_, $results{$_}/TRIALS, $ps{$_},
abs($results{$_}/TRIALS - $ps{$_});
}</
Sample output:
Line 2,416:
=={{header|Phix}}==
<!--<
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #008080;">constant</span> <span style="color: #000000;">lim</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">1000000</span><span style="color: #0000FF;">,</span>
Line 2,443:
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%6s %8.6f %8.6f\n"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">names</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">],</span><span style="color: #000000;">results</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">]/</span><span style="color: #000000;">lim</span><span style="color: #0000FF;">,</span><span style="color: #000000;">probs</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">]})</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
<!--</
{{out}}
<pre>
Line 2,458:
=={{header|Phixmonti}}==
<
by Galileo, 05/2022 #/
Line 2,486:
pop swap
1 get "\t" rot 3 get trial / "\t" rot 2 get nip "\n" 6 tolist lprint
endfor</
{{out}}
<pre>item actual theoretical
Line 2,502:
=={{header|PicoLisp}}==
<
(let Probs
(mapcar
Line 2,518:
(cdddr X)
(format (cadr X) 6)
(format (caddr X) 6) ) ) ) ) )</
Output:
<pre> Probability Result
Line 2,531:
=={{header|PL/I}}==
<
Dcl prob(8) Dec Float(15) Init((1/5.0), /* aleph */
(1/6.0), /* beth */
Line 2,575:
Put Edit(what(i),cnt(i),pr,prob(i))(Skip,a,f(10),x(2),2(f(11,8)));
End;
End;</
{{out}}
<pre>One million trials
Line 2,604:
{{trans|Java Script}}
The guts of this script are translated from the Java Script entry. Then I stole the idea to show the actual Hebrew character from Julia.
<syntaxhighlight lang="powershell">
$character = [PSCustomObject]@{
aleph = [PSCustomObject]@{Expected=1/5 ; Alpha="א"}
Line 2,651:
}
}
</syntaxhighlight>
{{Out}}
<pre>
Line 2,667:
=={{header|PureBasic}}==
<
Structure Item
Line 2,708:
Print(#CRLF$+"Press ENTER to exit"):Input()
CloseConsole()
EndIf</
Output may look like
Line 2,726:
=={{header|Python}}==
Two different algorithms are coded.
<
def probchoice(items, probs):
Line 2,789:
probs[-1] = 1-sum(probs[:-1])
tester(probchoice, items, probs, 1000000)
tester(probchoice2, items, probs, 1000000)</
Sample output:
Line 2,813:
Uses point$ from the bignum rational arithmetic module bigrat.qky. <code>10 point$</code> returns a ratio as a decimal string accurate to 10 decimal places with round-to-nearest on the final digit.
<
( --------------- zen object orientation -------------- )
Line 2,884:
drop ]
witheach [ report swap do ]</
{{out}}
Line 2,921:
=={{header|R}}==
<
# Note that R doesn't actually require the weights
# vector for rmultinom to sum to 1.
Line 2,928:
Requested = prob,
Obtained = hebrew/sum(hebrew))
print(d)</
Sample output:
Line 2,942:
A histogram of the data is also possible using, for example,
<
qplot(factor(names(prob), levels = names(prob)), hebrew, geom = "histogram")</
=={{header|Racket}}==
Line 2,954:
as a module. Either run the program in DrRacket or run `raco test prob-choice.rkt`
<
;;; returns a probabalistic choice from the sequence choices
;;; choices generates two values -- the chosen value and a
Line 3,040:
(test-p-c-function probabalistic-choice/exact test-weightings/50:50)
(test-p-c-function probabalistic-choice test-weightings/rosetta)
(test-p-c-function probabalistic-choice/exact test-weightings/rosetta))</
Output (note that the progress counts, which go to standard error, are
interleaved with the output on standard out)
Line 3,075:
(formerly Perl 6)
{{works with|Rakudo|2018.10}}
<syntaxhighlight lang="raku"
constant @event = <aleph beth gimel daleth he waw zayin heth>;
Line 3,093:
$expected,
abs $occurred - $expected;
}</
{{out}}
<pre>Event Occurred Expected Difference
Line 3,106:
=={{header|ReScript}}==
<
("Aleph", 1.0 /. 5.0),
("Beth", 1.0 /. 6.0),
Line 3,148:
}
)
}</
{{output}}
<pre>
Line 3,166:
A little extra REXX code was added to provide head and foot titles along with the totals.
<
parse arg trials digs seed . /*obtain the optional arguments from CL*/
if trials=='' | trials=="," then trials= +1e6 /*Not specified? Then use the default.*/
Line 3,197:
left( format( @.cell/trials * 100, d), w-2) /* [↓] foot title. [↓] */
if cell==# then say center(_,15,_) center(_,d,_) center(_,w,_) center(_,w,_)
end /*c*/ /*stick a fork in it, we are all done.*/</
{{out|output|text= when using the default input:}}
<pre>
Line 3,214:
=={{header|Ring}}==
<
# Project : Probabilistic choice
Line 3,237:
see "" + item[i] + " " + cnt[i]/1000000 + " " + prob[i] + nl
next
</syntaxhighlight>
Output:
<pre>
Line 3,252:
=={{header|Ruby}}==
<
"aleph" => 1/5.0,
"beth" => 1/6.0,
Line 3,288:
val = probabilities[k]
printf "%-8s%.8f %.8f %6.3f %%\n", k, val, act, 100*(act-val)/val
end</
{{out}}
Line 3,304:
=={{header|Rust}}==
<
use rand::distributions::{IndependentSample, Sample, Weighted, WeightedChoice};
Line 3,430:
let counts = take_samples(&mut rng, &wc);
print_mapping(&counts);
}</
{{out}}
<pre> ~~~ U32 METHOD ~~~
Line 3,458:
=={{header|Scala}}==
This algorithm consists of a concise two-line tail-recursive loop (<tt>def weighted</tt>). The rest of the code is for API robustness, testing and display. <tt>weightedProb</tt> is for the task as stated (0 < <i>p</i> < 1), and <tt>weightedFreq</tt> is the equivalent based on integer frequencies (<i>f</i> >= 0).
<
import scala.collection.mutable.LinkedHashMap
Line 3,521:
println("Checking weighted frequencies:")
check(frequencies.map{case (a, b) => a -> b.toDouble}, for (i <- 1 to 1000000) yield weightedFreq(frequencies))
}</
{{out}}
<pre>Checking weighted probabilities:
Line 3,549:
Using guile scheme 2.0.11.
<
(define (random-choice probs)
Line 3,593:
(he 1/9) (waw 1/10) (zayin 1/11) (heth 1759/27720)))
(format-results probs (choices 1000000 probs))</
Example output:
Line 3,608:
=={{header|Seed7}}==
To reduce the runtime this program should be compiled.
<
include "float.s7i";
Line 3,652:
100.0 * flt(table[aLetter]) / 27720.0 digits 4 lpad 8 <& "%");
end for;
end func;</
Outout:
Line 3,669:
=={{header|Sidef}}==
{{trans|Perl}}
<
func prob_choice_picker(options) {
Line 3,709:
abs(v/TRIALS - ps{k})
);
}</
{{out}}
Line 3,725:
=={{header|Stata}}==
<
mata
letters="aleph","beth","gimel","daleth","he","waw","zayin","heth"
Line 3,732:
st_addvar("str10","a")
st_sstore(.,.,a)
end</
=={{header|Tcl}}==
<
set map [dict create]
Line 3,771:
]
}
}</
<pre>using 1000000 samples:
expected actual difference
Line 3,789:
implemented by the run time system.
<
#import nat
#import flo
Line 3,806:
#show+
results = format simulation 1000000</
output:
<pre>
Line 3,821:
=={{header|VBScript}}==
Derived from the BBC BASIC version
<syntaxhighlight lang="vb">
item = Array("aleph","beth","gimel","daleth","he","waw","zayin","heth")
prob = Array(1/5.0, 1/6.0, 1/7.0, 1/8.0, 1/9.0, 1/10.0, 1/11.0, 1759/27720)
Line 3,853:
WScript.StdOut.Write item(i) & vbTab & FormatNumber(cnt(i)/1000000,6) & vbTab & FormatNumber(prob(i),6)
WScript.StdOut.WriteLine
Next</
{{out}}
Line 3,871:
{{trans|Kotlin}}
{{libheader|Wren-fmt}}
<
import "/fmt" for Fmt
Line 3,906:
}
System.print("\t-------- --------")
Fmt.print("\t$8.6f 1.000000", sumActual)</
{{out}}
Line 3,926:
=={{header|XPL0}}==
<
def Size = 10_000_000;
int Tbl(12+1);
Line 3,952:
");
RlOut(0, S0); RlOut(0, S1);
]</
Output:
Line 3,969:
=={{header|Yabasic}}==
<
data "aleph", "beth", "gimel", "daleth", "he", "waw", "zayin", "heth"
letters$(0) = "aleph"
Line 4,023:
print " -------- --------"
print " ", sumActual using "#.######", tab$, "1.000000"
end</
=={{header|zkl}}==
{{trans|C}}
<
"he", "waw", "zayin", "heth");
var ptable=T(5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0).apply('/.fp(1.0));
Line 4,048:
"%6s%7d %7.4f%% %7.4f%%".fmt(names[i], r[i], r[i]/M*100,
ptable[i]*100).println();
}</
{{out}}
<pre>
|