20% der Studenten einer Stadt studieren Informatik?

1 Antwort

(a) 0,1? also 10%? wegen 100%-50%-40%=10%

(b) 20% der InfStudis studieren an der WU... also: einen Studi der WU zu erwischen, ist 40%... 20% der Studis sind InfStudis... es sind 20% der InfStudis an der WU... also sind 0,2·0,2=0,04 (4%) der Studis WUInfStudis... also erwischt man mit WK 4% einen WUInfStudi... da würde ich jetzt 0,4·(1-0,04)=0,384 raten... müsste man aber wenigstens mit Monte-Carlo-Simulation nachprüfen...🥴

(c) steht schon da: 0,4

(d) ich hab noch von (b) einen Knoten im Gehirn... 40% der InfStudis sind TUStudis... 20% der Studis sind InfStudis... 0,2·0,4=0,08 der Studis sind TUInfStudis... Monte-Carlo-Simulation... aua... 🥴

Woher ich das weiß:Studium / Ausbildung
LUKEars  25.01.2023, 10:20

zu (b):

#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <inttypes.h>

void A() {
  const uint32_t C = 1000*1000*1000;
  uint64_t cnt = 0;
  for (uint32_t l=C; l>0; l--) {
      uint32_t R=random();
      bool isWU = R%100<40;
      R /= 100;
      bool isINF = R%100<20;
      R /= 100;
      bool isWUinf = isINF ? (R%100<20) : 0;
      if (isWU && !isWUinf) cnt++;
  }
  printf("games:%u cnt:%ju --> %.3f\n",C,cnt,cnt/(double)C);
}

int main(int argc, char ** argv) {
  unsigned seed; read(0,&seed,sizeof(seed)); srandom(seed);
  A();
  return 0;
}

ergibt:

> c++ -o a a.c -O3 && time (dd if=/dev/urandom bs=4 count=1|./a)
1+0 records in
1+0 records out
4 bytes copied, 7.2633e-05 s, 55.1 kB/s
games:1000000000 cnt:383977819 --> 0.384

real    1m1.079s
user    1m0.864s
sys    0m0.040s
0
LUKEars  25.01.2023, 10:21

zu (d):

#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <inttypes.h>

void A() {
  const uint32_t C = 1000*1000*1000;
  uint64_t tuinf = 0;
  uint64_t tu = 0;
  for (uint32_t l=C; l>0; l--) {
      uint32_t R=random();
      bool isTU = R%100<10;
      if (!isTU) continue;
      R /= 100;
      bool isINF = R%100<20;
      R /= 100;
      bool isTUinf = isINF ? (R%100<40) : 0;
      tu++; if (isTUinf) tuinf++;
  }
  printf("games:%u tu:%ju(%.3f) inf|tu:%ju(%.3f)\n",C,tu,tu/(double)C,tuinf,tuinf/(double)tu);
}

int main(int argc, char ** argv) {
  unsigned seed; read(0,&seed,sizeof(seed)); srandom(seed);
  A();
  return 0;
}

ergibt:

> c++ -o a a.c -O3 && time (dd if=/dev/urandom bs=4 count=1|./a)
1+0 records in
1+0 records out
4 bytes copied, 5.643e-05 s, 70.9 kB/s
games:1000000000 tu:99999652(0.100) inf|tu:8000779(0.080)

real    1m0.604s
user    1m0.442s
sys    0m0.000s
0