필터 지우기
필터 지우기

Using normrnd for generating natural values (without decimal values)

조회 수: 1 (최근 30일)
Sahar khalili
Sahar khalili 2022년 6월 14일
편집: Walter Roberson 2022년 6월 15일
I would like to generate data with average of 27 and standard deviation of 1.41, but I would like the data have no decimal values, ex to be like this 12, 24, 27 ... . Could you please help me how I can do so?
  댓글 수: 4
Walter Roberson
Walter Roberson 2022년 6월 14일
You cannot use the fact that the sum of identically distributed uniform distribution approximates normal. You can generate 54 binary values and sum them. That will have a mean of 27, but the std will be 3.67.
Sahar khalili
Sahar khalili 2022년 6월 14일
As I mentioned I do not care about the distributation of data, I need 6 numbers that just have the mean of 27 and std deviation of 1.41, and what matters for me is just data has no decimal values.

댓글을 달려면 로그인하십시오.

답변 (1개)

Sam Chak
Sam Chak 2022년 6월 14일
편집: Sam Chak 2022년 6월 14일
How about this data set {25, 26, 27, 27, 28, 29}?
A = [25, 26, 27, 27, 28, 29]
A = 1×6
25 26 27 27 28 29
M = mean(A)
M = 27
S = std(A)
S = 1.4142
  댓글 수: 5
Walter Roberson
Walter Roberson 2022년 6월 14일
[x1, x2, x3, x4, x5, x6] = ndgrid(27-4:27+4);
meanmask = (x1 + x2 + x3 + x4 + x5 + x6)/6 == 27;
sx1 = x1(meanmask); sx2 = x2(meanmask); sx3 = x3(meanmask);
sx4 = x4(meanmask); sx5 = x5(meanmask); sx6 = x6(meanmask);
sx = [sx1, sx2, sx3, sx4, sx5, sx6];
st = std(sx, [], 2);
inrange = st >= 1.405 & st < 1.415;
values_that_work = sx(inrange,:);
whos values_that_work
Name Size Bytes Class Attributes values_that_work 360x6 17280 double
unique(sort(values_that_work, 2), 'rows')
ans = 1×6
25 26 27 27 28 29
360 matches... but to within permutations they are all the same.
Notice that, as predicted by my analysis, no deviations of 4 or 3 match, only -2, -1, 0, 0, +1, +2
Sam Chak
Sam Chak 2022년 6월 15일
Many thanks to @Walter Roberson for explaning and showing the Permutation search procedure. The permutation-based method is effective.

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by