simbinom.m

来自「用matalab开发的随机数生成程序包」· M 代码 · 共 20 行

M
20
字号
function [sample] = simbinom(npoints, n, p)
% SIMBINOM random numbers from binomial distribution
%
% [sample] = simbinom(npoints, n, p)
%
% Inputs: npoints - sample size
%         n - parameter of the distribution, number of trials
%         p - parameter of the distribution, probability of success
%
% Outputs: sample - vector of random numbers
%
% See also SIMDISCR, SIMEXP, SIMGEOM, SIMPARETO

% Authors: R.Gaigalas, I.Kaj
% v1.2 04-Oct-02

  % generate n samples from Bernoulli and sum up
  sample = sum(rand(n, npoints)<p);  

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?