English
Source / code snippets

Rencontres-number, Derangement, Subfakultät: The Trachtenhut-Algorithmus

 

p.specht

Statistik/Kombinatorik: 5 Bauern blow one blast your 5 Trachtenhüte of head. in the confusion can any itself but again a hat round up. How big is the chance, that very 3 the 5 Bauern ihren originalen hat erwischt having?
Window Title "RENCONTRES-number, DERANGEMENT and SUBFAKULTÄT"
' (CL)Copyleft 2011ff P.woodpecker for Profaner
' attempt of/ one Umsetzung the Wikipedia-Artikels betr. Rencontres-number
' in XProfan 11.2a, NO GEWÄHR - No warranty whatsoever!
Font 2
declare p!,n!,k!,reindeer!,i&
moreover:
cls
Print " in the KOMBINATORIK understand one under the RENCONTRES-number   "
print " (french for 'Begegnungen') The with D(n;k) designated   "
print " amount jener PERMUTATIONEN of/ one crowd n unterscheidbarer    "
print " items, with the very k items ihren ursprünglichen or. "
print " a designed desired Space receive (and n-k not)."
print " Ren=D(n;k)=n!/k!*SUM[i=0..(n-k)](-1)^i/i!=(n OVR k)*D(n-k;0) "
print "                                                              "
print " for the drop, that KEINES the n items its Space one-   "
print " takes or. 'wiederfindet', yields as Sonderfall The    "
print " Formel for number möglicher DERANGEMENTS or 'Totalver-   "
print " setzungen' all n items To  !n = 'SUBFAKULTÄT of n'     "
print " to the Formel:  !n = D(n;0) = n! * SUM[i=0..n](-1)^i/i!    "
' print " {interestingly: lim[n..+Inf](SUM[i=0..n](-1)^i/i!))= 1/exp(1)} "
Print "                                                              "
Print " Bsp: amount n the To permutierenden items prompt: ";:input n!

if n!>15

    print " because of upper Integer-boundary Please only numbers To 15 - Sorry! "
    WaitInput
    goto "weiter"

endif

print " in principle were it "; int(fakul(n!)); " Positions-Permutationen."
Print "                                                              "
Print " Wieviele items should in Wunschposition stand?: 0";:input k!
'print "                                                              "
print " then there very ";
Ren!=Rencontres_D(n!,k!)
set("decimals",0)
print reindeer!;" such Permutationen."
set("decimals",3)
print " The probability for so a Stellung is ";100*reindeer!/fakul(int(n!));"%"
set("decimals",0)
WaitInput
goto "Weiter"

Proc Rencontres_D : parameters n!,k!

    var n&=int(n!)
    var k&=int(k!)
    var p!=1

    whileLoop k&+1,n&

        p!=p!*&Loop

    EndWhile

    var s!=0
    var i&=0

    while i&<=(n&-k&)

        s! = s! + (1.0-2.0*(i& mod 2)) / fakul(i&)
        inc i&

    endwhile

    'print "Vorfaktor: ";p!
    'print "    amount: ";s!
    return p! * s!

ENDPROC

Proc fakul

    parameters p&
    var prd!=1
    case p&<1 : p&=1
    case p&>169 :prd! = -1
    case prd!<0: goto "back"

    whileloop p&,1,-1

        prd!=prd!*&Loop

    endwhile

    back:
    return prd!

ENDPROC

 
XProfan 11
Computer: Gerät, daß es in Mikrosekunden erlaubt, 50.000 Fehler zu machen, zB 'daß' statt 'das'...
04/15/21  
 



Zum Quelltext


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

696 Views

Untitledvor 0 min.
N.Art07/23/21
Glubbfan06/19/21
Uwe ''Pascal'' Niemeier06/13/21
Walter04/25/21
More...

Themeninformationen

this Topic has 1 subscriber:

p.specht (1x)


Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie