楼主: 唐伯小猫
1627 3

[问答] 哪位同学给具体解释,谢谢 [推广有奖]

  • 1关注
  • 16粉丝

VIP

学科带头人

12%

还不是VIP/贵宾

-

威望
0
论坛币
5371 个
通用积分
3.2876
学术水平
22 点
热心指数
28 点
信用等级
20 点
经验
36757 点
帖子
1428
精华
0
在线时间
1541 小时
注册时间
2005-10-3
最后登录
2022-8-28

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币

ind<-sample(2,nrow(iris),replace=TRUE,prob=c(0.7,0.3)

哪位同学给具体解释一下上面的话,我只知道iris 是数据,其他都不是很不明白,谢谢
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:IND replace

心若向阳,无畏悲伤。
沙发
danica33 发表于 2014-4-2 22:34:42 |只看作者 |坛友微信交流群
随机变量X服从两点分布:P(X=1)=0.7,P(X=2)=0.3,上述命令就是产生nrow(iris)个X的随机数。
nrow(iris)是数据的行数。

使用道具

藤椅
Aharach 发表于 2014-4-3 02:13:47 |只看作者 |坛友微信交流群
有时候,一个"?sample" 比到论坛上找解释还要快:
Random Samples and Permutations

Description

sample takes a sample of the specified size from the elements of x using either with or without replacement.

Usage

sample(x, size, replace = FALSE, prob = NULL)

sample.int(n, size = n, replace = FALSE, prob = NULL)
Arguments

x       
Either a vector of one or more elements from which to choose, or a positive integer. See ‘Details.’

n       
a positive number, the number of items to choose from. See ‘Details.’

size       
a non-negative integer giving the number of items to choose.

replace       
Should sampling be with replacement?

prob       
A vector of probability weights for obtaining the elements of the vector being sampled.

使用道具

板凳
唐伯小猫 发表于 2014-4-3 13:33:06 |只看作者 |坛友微信交流群
太好了, 谢谢楼上2位好心童鞋!!
心若向阳,无畏悲伤。

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-5-5 11:26