# Clean way to use mean value with distributions

**URL:** <https://discourse.julialang.org/t/clean-way-to-use-mean-value-with-distributions/108580>\
**Category:** New to Julia\
**Tags:** monte-carlo, language-support\
**Created:** [January 9, 2024, 6:03pm UTC](https://discourse.julialang.org/t/clean-way-to-use-mean-value-with-distributions/108580 "2024-01-09T18:03:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lenz](https://avatars.discourse-cdn.com/v4/letter/l/ce73a5/32.png) [@lenz](https://discourse.julialang.org/u/lenz)\
**Post date:** [January 9, 2024, 6:03pm UTC](https://discourse.julialang.org/t/clean-way-to-use-mean-value-with-distributions/108580/1 "2024-01-09T18:03:30Z")

</div>

I have a model that is called with a strut with all the arguments (with units) needed. I would like to use this model to do uncertainty analysis by setting some of these values to a distribution.

I would like to be able to run the model with the expected values of the distributions, but also take draws when I’m running an uncertainty analysis.

Currently, what I do is I create a dist for a parameter I want changed and just set it in a for loop similar to this:

dist = Normal(Param.x, 1)  
for i = 1:10  
Param.x = rand(dist)  
model(Param)  
[…]  
end

This works, but is cumbersome if I want to change the parameters I want to study or if I want to share my code.

What is the best way to do this?
