File:Probabilite nd6.svg

Summary

Category:Files by User:cdang
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 )
Other versions raster version: Probabilite nd6.png; subsets: Probabilite nd6 fonction masse.svg, Probabilite nd6 fonction densite.svg
SVG development
InfoField
 The source code of this SVG is invalid due to 87 errors.
 This W3C-invalid vector image was created with Scilab by cdang.
Category:Invalid SVG created with Scilab#0011Probabilite%20nd6.svg
 Category:Translation possible - SVGThis file uses embedded text that can be easily translated using a text editor.

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

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.
Category:License migration redundant#Probabilite%20nd6.svgCategory:GFDL#Probabilite%20nd6.svg
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons 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.
Category:CC-BY-SA-4.0,3.0,2.5,2.0,1.0#Probabilite%20nd6.svg
You may select the license of your choice.
Category:Self-published work
Category:Dice probability
Category:CC-BY-SA-4.0,3.0,2.5,2.0,1.0 Category:Dice probability Category:Files by User:cdang Category:GFDL Category:Images with Scilab code Category:Invalid SVG created with Scilab Category:License migration redundant Category:Self-published work Category:Translation possible - SVG