cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
Yogeshl
Level II

Random data generation with given mean and 95% CI

Hi All,

 

1. Can we generate random data from given Mean & 95% confidence range?. Like I need to generate 100 data with give mean (50) and 95% confidence interval (45-56).

 

2. In other way, with mean and standard deviation data can be generated but can standard deviation be calculated from 95% CI range?

 

Regards,

Yogeshl

5 REPLIES 5
jthi
Super User

Re: Random data generation with given mean and 95% CI

Yogeshl
Level II

Re: Random data generation with given mean and 95% CI

Thank you, I also saw these while googling but it did not work for me.

P_Bartell
Level VIII

Re: Random data generation with given mean and 95% CI

I agree with @jthi 's idea of back calculating your way to a standard deviation that will yield a population mean with some desired confidence level. But you'll only get part way there. I see two issues...since you are constraining yourself to just N = 100. Every time you run JMP's random number generator for a normal distribution with a prescribed mean and standard deviation, you'll get 100 numbers...but the mean and confidence interval will not be exactly what you desire...it will be close...but not exact. Rerun the random number generator and you'll get a different answer. So you can't get there exactly. The other issue I see, and maybe I'm just being too literal here...but in your original post the confidence interval you seek is not symmetrical about the mean...your stated mean = 50 and the lower limit is 45, upper limit is 56. Again...can't be done using standard population confidence interval methods.

Yogeshl
Level II

Re: Random data generation with given mean and 95% CI

Thank you for explanation, I understand possibility is less but wanted to know is anyone tried it before or may suggest some path to generate data which can be used further.

Georg
Level VII

Re: Random data generation with given mean and 95% CI

Looks somehow weird to me, not sure what for it is needed.

Maybe this could be a way to do this, see the JSL script.

As @P_Bartell pointed out already, we need a lot of more rows to see exactly (2 digits or so) the numbers you want. And we need to manipulate the distribution to show that values you want (unsymmetry).

The stretching did change the mean by 0.2, this I did not account for ...

Of course you could calculate 100 rows only and manipulate them i a way to get that exact numbers you want ...

Or you can work with random seed, to generate exactly the same random numbers next time.

You see, JMP can do it all ..., welcome to the community.

Good luck.

 

Georg_0-1658947159848.png

Names Default To Here( 1 );

// Generate data with 95 % Confidence between 45 and 56 with mean of 50
// 

// returns the probability that a normally distributed random variable is less than q (45)
Normal Distribution( 45, 50, 5 );
// 0.158655, i.e. roughly 15 % of values are below 45 for a normal distribution with Average=50 and sigma=5

// Returns the quantile from a Normal distribution, the value for which the probability is p that a random value would be lower
quantile = Normal Quantile( 0.025 );
// -1.959964, i.e. 2.5 % of the values are below -1.959964, or smaller than Average minus -1.959964*sigma

// we need this quantile and have the absolute difference 2.5 % left + 2.5 % right = 5 % out, i.e. 95 % in
sigma = Abs( (50 - 45) / quantile );

Normal Distribution( 45, 50, sigma );
// 0.025, this is what we want

// now we can generate a table with that distribution
// and will scale the upper half by 6/5 to have the probability of 55 at 56 in a second column value_rightstretched

dt = New Table( "random confidence 45 50 56 95%",
	add rows( 1000000 ),
	New Column( "value", set each value( Random Normal( 50, sigma ) ) , Set Property("Spec Limits", {LSL(45), USL(55), Target(50), Show Limits(1)}),),
	New Column( "value_rightstretched", formula( If( :value > 50, (:value - 50) * 6 / 5 + 50, :value ) ) , Set Property("Spec Limits", {LSL(45), USL(56), Target(50), Show Limits(1)}),)
);

dt << Distribution(
	Continuous Distribution(
		Column( :value ),
		Outlier Box Plot( 0 ),
		Process Capability( Use Column Property Specs ),
		Customize Summary Statistics( Set Alpha Level( 0.01 ) )
	),
	Continuous Distribution(
		Column( :value_rightstretched ),
		Outlier Box Plot( 0 ),
		Process Capability( Use Column Property Specs ),
		Customize Summary Statistics( Set Alpha Level( 0.01 ) )
	)
);

 

 

Georg