File:Probabilite nd6.svg

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

Original file(SVG file, nominally 507 × 457 pixels, file size: 234 KB)

Captions

Captions

Add a one-line explanation of what this file represents

Summary[edit]

Description
Français : Probabilités comparées d'avoir un résultat (haut) ou de faire moins qu'un seuil donné (bas) en sommant plusieurs dés à six faces (nd6).
English: Probabilities to get a number (top) or to have less than a given threshold (bottom) by summing several six-sided dice (nd6).
Date
Source Own work
Author Christophe Dang Ngoc Chan (Cdang (talk))
Other versions raster version: File:Probabilite nd6.png; subsets: File:Probabilite nd6 fonction masse.svg, File:Probabilite nd6 fonction densite.svg

Scilab source

// Calcul de probabilités de jets de dés par dénombrement

function [frequences]=tirages(nb_d, nb_faces)
    // calcule les fréquences de nb_d tirage de dés par dénombrement
    // entrées :    nb_d : nombre de tirages (entier)
    //              nb_faces : nombre de faces du dé
    // sorties : frequences : matrice de fréquences (réels)
    
    N = nb_faces^nb_d; // nombre de valeurs possibles
    resultats = zeros(N, nb_d); // initialisation : résultats des tirages
    for i = 1:nb_d // n° de colonne
        k = nb_faces^(nb_d - i); //à la colonne i,
        //  on alterne k valeurs 0 et k valeurs 1
        for j=0:nb_faces^(i - 1) - 1
            for jj = 1:nb_faces
                resultats((nb_faces*j + jj - 1)*k + 1:(nb_faces*j + jj)*k, i)...
                = jj;
            end
        end
    end
    //disp(resultats);
    somme = sum(resultats, "c");
    frequences_non_triees = tabul(somme);
    frequences = gsort(frequences_non_triees, "lr", "i");
    frequences(:,2) = 100*frequences(:,2)/N; // normalisation des fréquences
endfunction

// génération des valeurs

freq_1d6 = tirages(1, 6);
freq_2d6 = tirages(2, 6);
freq_3d6 = tirages(3, 6);
freq_4d6 = tirages(4, 6);
freq_5d6 = tirages(5, 6);

freq_cumul_1d6 = freq_1d6;
freq_cumul_1d6(:, 2) = cumsum(freq_1d6(:, 2))
freq_cumul_2d6 = freq_2d6;
freq_cumul_2d6(:, 2) = cumsum(freq_2d6(:, 2))
freq_cumul_3d6 = freq_3d6;
freq_cumul_3d6(:, 2) = cumsum(freq_3d6(:, 2))
freq_cumul_4d6 = freq_4d6;
freq_cumul_4d6(:, 2) = cumsum(freq_4d6(:, 2))
freq_cumul_5d6 = freq_5d6;
freq_cumul_5d6(:, 2) = cumsum(freq_5d6(:, 2))

// Tracé

scf(0);
clf;

cmap = zeros(5, 3);
cmap(:,1) = linspace(0, 0.5, 5)';
cmap(:,2) = cmap(:,1);
cmap(:, 3) = ones(5)';
xset("colormap", cmap)

subplot(2, 1, 1)
plot2d(freq_1d6(:, 1), freq_1d6(:, 2), style=1)
courbe = gce();
courbe.children.mark_style = 1;
courbe.children.mark_foreground = 1;
plot2d(freq_2d6(:, 1), freq_2d6(:, 2), style=2)
courbe = gce();
courbe.children.mark_style = 2;
courbe.children.mark_foreground = 2;
plot2d(freq_3d6(:, 1), freq_3d6(:, 2), style=3)
courbe = gce();
courbe.children.mark_style = 3;
courbe.children.mark_foreground = 3;
plot2d(freq_4d6(:, 1), freq_4d6(:, 2), style=4)
courbe = gce();
courbe.children.mark_style = 4;
courbe.children.mark_foreground = 4;
plot2d(freq_5d6(:, 1), freq_5d6(:, 2), style=5)
courbe = gce();
courbe.children.mark_style = 5;
courbe.children.mark_foreground = 5;

xtitle("Fréquences (probabilité d''avoir une valeur)",...
    "résultat des dés", "probabilité (%)")
legend("1d6", "2d6", "3d6", "4d6","5d6")

subplot(2, 1, 2)
plot2d(freq_cumul_1d6(:, 1), freq_cumul_1d6(:, 2), style=1)
courbe = gce();
courbe.children.mark_style = 1;
courbe.children.mark_foreground = 1;
plot2d(freq_cumul_2d6(:, 1), freq_cumul_2d6(:, 2), style=2)
courbe = gce();
courbe.children.mark_style = 2;
courbe.children.mark_foreground = 2;
plot2d(freq_cumul_3d6(:, 1), freq_cumul_3d6(:, 2), style=3)
courbe = gce();
courbe.children.mark_style = 3;
courbe.children.mark_foreground = 3;
plot2d(freq_cumul_4d6(:, 1), freq_cumul_4d6(:, 2), style=4)
courbe = gce();
courbe.children.mark_style = 4;
courbe.children.mark_foreground = 4;
plot2d(freq_cumul_5d6(:, 1), freq_cumul_5d6(:, 2), style=5)
courbe = gce();
courbe.children.mark_style = 5;
courbe.children.mark_foreground = 5;

xtitle("Fréquences cumulées (probabilité de faire moins qu''une valeur)",...
    "résultat des dés", "probabilité (%)")

Licensing[edit]

I, the copyright holder of this work, hereby publish it under the following licenses:
GNU head Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled GNU Free Documentation License.
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike Attribution-Share Alike 4.0 International, 3.0 Unported, 2.5 Generic, 2.0 Generic and 1.0 Generic license.
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.
You may select the license of your choice.

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current15:16, 25 October 2013Thumbnail for version as of 15:16, 25 October 2013507 × 457 (234 KB)Cdang (talk | contribs)complete version
15:12, 25 October 2013Thumbnail for version as of 15:12, 25 October 2013507 × 227 (133 KB)Cdang (talk | contribs){{Information |Description={{fr|1=Probabilités comparées d'avoir un résultat (haut) ou de faire moins qu'un seuil donné (bas) en sommant plusieurs dés à six faces (nd6).}} {{en|1=Probabilities to get a number (top) or to have less than a given th...

The following page uses this file:

Metadata