Sample size

A list of N random numbers between 0 and 1 is being generated

list1 is being being reduced to the first n elements

Number of Parties

PopulationFrequencyCumulative

Votes are being counted for each party in the reduced list up to n

The list of Votes are being converted to percentages

Stikprøvestørrelse (N):

Width of columns in BarChart

Udtag stikprøve

Parti

Populationsfrekvens (%)

\text{Parti} & \text{Population}& \text{Stikprøve} & \text{Forskel}\ & \text{frekvens (\%)} & \text{frekvens (\%)} & \text{(\%)}

Antal partier:

C

FEJL! En frekvens er ikke mellem 0 og 100, eller en celle er tom. 
(Husk at kontrollere værdien, der står i input-boksen “Antal partier”)

A

B

D

E

NPnew = 5 (slider from 2 to 10)
PopFreqSpreadsheet = Sequence(Cell[2, i], i, 2, NPnew + 1)
flagPopFreqValid1: Min[PopFreqSpreadsheet] ≥ 0 ∧ Max[PopFreqSpreadsheet] ≤ 100
n = 1000 (slider from 1 to N, step 1)
N = 1000 (slider from 0 to 10000)
list1 = Sequence(random(), i, 1, N)
list2 = First(list1, n)
NP = 5 (slider from 1 to 20)
PopulationFrequencies: {0.127, 0.231, 0.065, 0.312, 0.265}
PFC = Append(0, Sequence[Sum[PopulationFrequencies, k], k, 1, Length[PopulationFrequencies]])
Votes = Frequency(PFC, list2)
SampleProcentages: (Votes / n * 100)
listTextTableColSampleFreq = Zip(If[P < 100, "\hphantom{0}", ""] + (floor(P / 10)) + "." + (Mod[P, 10]), P, round((10 * SampleProcentages)))
PopulationProcentages: (PopulationFrequencies * 100)
listTextTableColPopFreq = Zip(If[P < 100, "\hphantom{0}", ""] + (floor(P / 10)) + "." + (Mod[P, 10]), P, round((10 * PopulationProcentages)))
SampleDifferences: SampleProcentages - PopulationProcentages
Nnew = 1000 (slider from 1 to 10000)
SampleSize = Textfield(Nnew)
Cwidth = 0.1 (slider from -5 to 5)
BarChartPopulation = BarChart(0, (Cwidth * NP), PopulationFrequencies)
BarChartSample = BarChart(0, (Cwidth * NP), Votes / N)
listTextTableColDiff = Zip(If[P < 0, "-", "+"] + (If[abs(P) < 100, "\hphantom{0}", ""]) + (floor(abs(P) / 10)) + "." + (Mod[abs(P), 10]), P, round((10 * SampleDifferences)))
Parties: {"A", "B", "C", "D", "E"}
listTextTableRows = Zip("\text{" + (P) + "}&" + (F1) + "&" + (F2) + "&" + (F3) + "\\", P, Parties, F1, listTextTableColPopFreq, F2, listTextTableColSampleFreq, F3, listTextTableColDiff)
textTableRows = Sum(listTextTableRows)
NumberOfParties = Textfield(NPnew)
flagPopFreqValid2: Sum[PopFreqSpreadsheet] ≟ 100
textTableVer1: "\begin{tabular}{|c|c|c|c|}
\hline
\multicolumn{4}{|l|}{\text{Stikprøvestørrelse: }" + (LaTeX[n]) + "}\\
\hline " + (LaTeX[textTableHeader]) + "\\
\hline " + (LaTeX[textTableRows]) + "

\hline
\end{tabular}"
B2: 12.7000000000000
textInvalidPopFreq2: "FEJL! Summen af frekvenserne er ikke 100. 
Summen af frekvenserne for de " + NPnew + " partier er " + (Sum[PopFreqSpreadsheet]) + ".
(Husk at kontrollere værdien indtastet i input-boksen “Antal partier“"
B3: 23.1000000000000
B5: 31.2000000000000
B6: 26.5
B4: 6.5