এই টিউটোরিয়ালে, আমরা সি++-এ negative_binomial_distribution সম্পর্কে আলোচনা করব।
এই ফাংশন নেগেটিভ বাইনোমিয়াল ডিসক্রিট ডিস্ট্রিবিউশন অনুসরণ করে এবং এই র্যান্ডম ডিস্ট্রিবিউশন অনুযায়ী পূর্ণসংখ্যা প্রডিউস করে।
উদাহরণ
#include <bits/stdc++.h> using namespace std; int main() { // পরীক্ষার সংখ্যা সেট const int exps = 10000; const int numberstars = 100; default_random_engine generator; negative_binomial_distribution<int> distribution(4, 0.5); int p[10] = {}; for (int i = 0; i < exps; ++i) { int counting = distribution(generator); if (counting < 10) ++p[counting]; } cout << "Negative binomial distribution with "<< "( k = 4, p = 0.5 ) :" << endl; // অ্যারে থেকে সিকোয়েন্স প্রিন্ট for (int i = 0; i < 10; ++i) cout << i << ": " << string(p[i] * numberstars / exps, '*') << endl; return 0; }আউটপুট
Negative binomial distribution with ( k = 4, p = 0.5 ) : 0: ***** 1: ************ 2: **************** 3: *************** 4: ************* 5: ********** 6: ******** 7: ***** 8: *** 9: **