<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Change statistical moments/parameters of a sample in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Change-statistical-moments-parameters-of-a-sample/m-p/244175#M12882</link>
    <description>&lt;P&gt;Yes. As Rick said. It looks like you want draw some data from Normal Distribution with some special probability which&amp;nbsp;conform to Triangle Distribution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data tri;
call streaminit(1234);
do i=1 to 10000;
 x=rand('triangle',0.7);output;
end;
run;
title 'Triangle Distribution peak=0.7';
proc sgplot data=tri;
histogram x;
density x/type=kernel;
run;






%let peak=0.7;
title 'Simulation from Normal';
proc iml;
x=j(10000,1);
prob=j(10000,1);
z=j(10000,1);

call randseed(1234);
call randgen(x,'normal');
prob = cdf("Normal", x);
prob = choose((prob&amp;lt;=&amp;amp;peak),prob,2#&amp;amp;peak-prob);

z=sample(x,10000,"Replace", prob);
call histogram(z) density='kernel';

quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 18 Jan 2016 08:45:57 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2016-01-18T08:45:57Z</dc:date>
    <item>
      <title>Change statistical moments/parameters of a sample</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Change-statistical-moments-parameters-of-a-sample/m-p/243746#M12848</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is possible (and how) to take sample - similar to proc surveyselect -, but change certain statistical parameters of the sample? For example, take a normal distribution (uniform distribution is a bad example) and then&amp;nbsp;get a triangular-distributed&amp;nbsp;sample which has a certain mode?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&amp;amp;kind regards&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jan 2016 12:24:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Change-statistical-moments-parameters-of-a-sample/m-p/243746#M12848</guid>
      <dc:creator>user24feb</dc:creator>
      <dc:date>2016-01-15T12:24:02Z</dc:date>
    </item>
    <item>
      <title>Re: Change statistical moments/parameters of a sample</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Change-statistical-moments-parameters-of-a-sample/m-p/243758#M12849</link>
      <description>&lt;P&gt;It's possible in some cases, but the resulting "sample" is no longer random.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In general, every time you resample you will obtain&amp;nbsp;new sample statistics (mean, median, mode, &amp;nbsp;etc).&amp;nbsp; But it sounds like you want to predetermine a statistic, such as "I want the new mode to be 1.2."&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is the application for this process? What are you hoping to accomplish?&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jan 2016 12:59:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Change-statistical-moments-parameters-of-a-sample/m-p/243758#M12849</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2016-01-15T12:59:25Z</dc:date>
    </item>
    <item>
      <title>Re: Change statistical moments/parameters of a sample</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Change-statistical-moments-parameters-of-a-sample/m-p/243773#M12850</link>
      <description>&lt;P&gt;This is a very crude code, but it should show the basic idea. The actual data are "recipes" (a big number of bill of materials&amp;nbsp;consisting of different components with 'interesting areas'). This is, sampling the multivariate case for general distributions (not symmetric)&amp;nbsp;&lt;U&gt;and&lt;/U&gt;&amp;nbsp;correlation (because the percentages of the components add up to 100 %)&amp;nbsp;would be complete description. A SAS function for this is probably to much to hope for, but there might be articles about this problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;* Defines allowed values;
Data A;
  Do i=1 To 1000;
    X=Round(Rannor(1)*3+10,0.01);
	Output;
  End;
Run;

* is not skewed ..;
Proc Means Data=A Mean StdDev Skewness;
  Var X;
Run;

* 'nasty' way to get a kind of a triangular distribution;
Data B;
  Set A;
  Select ;
    When (X &amp;gt; 6 &amp;amp; X &amp;lt;= 7) Group=1;
	When (X &amp;gt; 7 &amp;amp; X &amp;lt;= 8) Group=2;
	When (X &amp;gt; 8 &amp;amp; X &amp;lt;= 9) Group=3;
	When (X &amp;gt; 9 &amp;amp; X &amp;lt;= 10) Group=4;
    Otherwise Group=0;
  End;
Run;

Proc Sort Data=B;
  By Group X;
Run;

* sample sizes give left skewed distribution ..;
Proc SurveySelect Data=B Out=C Method=srs N=(0 5 5 10 30);
  Strata Group;
Run;

Proc Means Data=C Mean StdDev Skewness;
  Var X;
Run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jan 2016 14:17:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Change-statistical-moments-parameters-of-a-sample/m-p/243773#M12850</guid>
      <dc:creator>user24feb</dc:creator>
      <dc:date>2016-01-15T14:17:17Z</dc:date>
    </item>
    <item>
      <title>Re: Change statistical moments/parameters of a sample</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Change-statistical-moments-parameters-of-a-sample/m-p/243802#M12853</link>
      <description>&lt;P&gt;Sound like you are wanting to do "probability sampling," where each observation is assigned a known probability of being selected.&amp;nbsp; In your case, you are assigning higher probability to observations greater than the mean and lower probability to observations that are less than the mean.&amp;nbsp; How you assign the probabilities&amp;nbsp;affects the moments of the resulting distribution, so the key to your problem will be deciding on a transformation that&amp;nbsp;generates a sampling probability from the data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have SAS/IML experience, you can request probability samples by using the SAMPLE function. In the following, I generate sampling weights by using the normal CDF of the standardized data.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
mu = 10; sigma = 3;
x = j(1000, 1);
call randgen(x, "Normal", mu, sigma);  /* x ~ N(10, 3) */

/* create probability scale based on z-score */
prob = cdf("Normal", (x - mu)/sigma);
y = sample(x, 50, "Replace", prob);  /* prob is standardized so sum(prob)=1 */

call histogram(y);  /* show skewed distribution */
mean = mean(y`);
skew = skewness(y`);
print mean skew;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Helvetica" size="5"&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jan 2016 15:35:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Change-statistical-moments-parameters-of-a-sample/m-p/243802#M12853</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2016-01-15T15:35:58Z</dc:date>
    </item>
    <item>
      <title>Re: Change statistical moments/parameters of a sample</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Change-statistical-moments-parameters-of-a-sample/m-p/244175#M12882</link>
      <description>&lt;P&gt;Yes. As Rick said. It looks like you want draw some data from Normal Distribution with some special probability which&amp;nbsp;conform to Triangle Distribution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data tri;
call streaminit(1234);
do i=1 to 10000;
 x=rand('triangle',0.7);output;
end;
run;
title 'Triangle Distribution peak=0.7';
proc sgplot data=tri;
histogram x;
density x/type=kernel;
run;






%let peak=0.7;
title 'Simulation from Normal';
proc iml;
x=j(10000,1);
prob=j(10000,1);
z=j(10000,1);

call randseed(1234);
call randgen(x,'normal');
prob = cdf("Normal", x);
prob = choose((prob&amp;lt;=&amp;amp;peak),prob,2#&amp;amp;peak-prob);

z=sample(x,10000,"Replace", prob);
call histogram(z) density='kernel';

quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Jan 2016 08:45:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Change-statistical-moments-parameters-of-a-sample/m-p/244175#M12882</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-01-18T08:45:57Z</dc:date>
    </item>
    <item>
      <title>Re: Change statistical moments/parameters of a sample</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Change-statistical-moments-parameters-of-a-sample/m-p/244204#M12884</link>
      <description>&lt;P&gt;Unfortunately, I only have STAT/ETS and OR, but I think I can build something similar. If there is something similar for those modules, please let me know.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2016 13:02:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Change-statistical-moments-parameters-of-a-sample/m-p/244204#M12884</guid>
      <dc:creator>user24feb</dc:creator>
      <dc:date>2016-01-18T13:02:39Z</dc:date>
    </item>
    <item>
      <title>Re: Change statistical moments/parameters of a sample</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Change-statistical-moments-parameters-of-a-sample/m-p/244221#M12886</link>
      <description>&lt;P&gt;Do you want to SIMULATE data from a triangular distribution? That's easy by using the DATA step and the "TRIANGLE" distribution. You can also &lt;A href="http://blogs.sas.com/content/iml/2012/10/24/pert-distribution.html" target="_self"&gt;simulate data from the PERT distribution&lt;/A&gt;, which is a generalization of the triangular distribution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please clarify: do you want to simulate from a probability distribution, or do you want to resample from existing data?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2016 14:32:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Change-statistical-moments-parameters-of-a-sample/m-p/244221#M12886</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2016-01-18T14:32:58Z</dc:date>
    </item>
    <item>
      <title>Re: Change statistical moments/parameters of a sample</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Change-statistical-moments-parameters-of-a-sample/m-p/244223#M12887</link>
      <description>I would like to resample existing data. (PERT would be nice too, but for my purpose a triangular dist. is sufficient)</description>
      <pubDate>Mon, 18 Jan 2016 14:37:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Change-statistical-moments-parameters-of-a-sample/m-p/244223#M12887</guid>
      <dc:creator>user24feb</dc:creator>
      <dc:date>2016-01-18T14:37:26Z</dc:date>
    </item>
    <item>
      <title>Re: Change statistical moments/parameters of a sample</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Change-statistical-moments-parameters-of-a-sample/m-p/244261#M12896</link>
      <description>&lt;P&gt;Here's what you want to do:&lt;/P&gt;
&lt;P&gt;1. Create a variable that contains the sampling probability for each observation&lt;/P&gt;
&lt;P&gt;2. Use the METHOD=PPS_WR option in PROC SURVEYSELECT to specify that you want a probability sample that is proportional to size (with replacement)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example, the following program assigns the first observation a 50% probability of being selected and the other eight observations a 6.25% probability.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data A;
do x = 1 to 9;
   if x=1 then prob = 0.5; /* 50% probability of selection */
   else prob = 0.5/8;      /*  6.25% probability of selection */
   output;
end;
run;

/* resample with probability proportional to size */
proc surveyselect data=A out=out method=PPS_WR 
     seed=123 N=100;
size prob;    /* specify the probability variable */
run;

/* examine the distribution of the observations */
proc freq data=out;
weight numberHits;
tables x;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Jan 2016 17:59:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Change-statistical-moments-parameters-of-a-sample/m-p/244261#M12896</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2016-01-18T17:59:29Z</dc:date>
    </item>
    <item>
      <title>Re: Change statistical moments/parameters of a sample</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Change-statistical-moments-parameters-of-a-sample/m-p/244346#M12897</link>
      <description>&lt;P&gt;Yes. Data step can do it, but need some more code .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data tri;
call streaminit(1234);
do i=1 to 10000;
 x=rand('triangle',0.7);output;
end;
run;
title 'Triangle Distribution peak=0.7';
proc sgplot data=tri;
histogram x;
density x/type=kernel;
run;


%let peak=0.7;
title 'Simulation from Normal';
data normal;
call streaminit(1234);
do i=1 to 10000;
 x=rand('normal');
 prob = cdf("Normal", x);
 p = ifn((prob&amp;lt;=&amp;amp;peak),prob,2*&amp;amp;peak-prob);
 output;
end;
drop prob i;
run;
proc sql noprint;
 select count(*) into : n from normal;

create table temp as
 select x,p/sum(p) as p from normal;
quit;
data want;
 set temp end=last;
 array xx{&amp;amp;n} _temporary_;
 array pp{&amp;amp;n} _temporary_;
 call streaminit(1234);
 xx{_n_}=x;
 pp{_n_}=p;
 if last then do;
  do i=1 to 10000;
   idx=rand('table',of pp{*});
   x=xx{idx};
   output;
  end;
 end;
run;
proc sgplot data=want;
histogram x;
density x/type=kernel;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 Jan 2016 03:33:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Change-statistical-moments-parameters-of-a-sample/m-p/244346#M12897</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-01-19T03:33:50Z</dc:date>
    </item>
    <item>
      <title>Re: Change statistical moments/parameters of a sample</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Change-statistical-moments-parameters-of-a-sample/m-p/244352#M12898</link>
      <description>&lt;P&gt;Here is the code base on Rick.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
%let peak=0.7;
title 'Simulation from Normal';
data normal;
call streaminit(1234);
do i=1 to 100000;
 x=rand('normal');
 prob = cdf("Normal", x);
 _RATE_= ifn((prob&amp;lt;=&amp;amp;peak),prob,2*&amp;amp;peak-prob);
 output;
end;
drop prob ;
run;

proc surveyselect data=normal  out=want method=PPS_WR N=10000;
size _RATE_;    /* specify the probability variable */
run;
proc sgplot data=want;
histogram x;
density x/type=kernel;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 Jan 2016 05:07:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Change-statistical-moments-parameters-of-a-sample/m-p/244352#M12898</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-01-19T05:07:42Z</dc:date>
    </item>
  </channel>
</rss>

