# Generate Struct based on stat distribution

**URL:** <https://discourse.julialang.org/t/generate-struct-based-on-stat-distribution/67040>\
**Category:** New to Julia\
**Tags:** question, statistics\
**Created:** [August 26, 2021, 2:15pm UTC](https://discourse.julialang.org/t/generate-struct-based-on-stat-distribution/67040 "2021-08-26T14:15:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rodolforbcoutinho](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rodolforbcoutinho/32/27067_2.png) [@rodolforbcoutinho](https://discourse.julialang.org/u/rodolforbcoutinho)\
**Post date:** [August 26, 2021, 2:15pm UTC](https://discourse.julialang.org/t/generate-struct-based-on-stat-distribution/67040/1 "2021-08-26T14:15:04Z")

</div>

Hello,  
I’m trying to generate a random data for a struct based on stat distribution. I think it should be a simple task, but probably i’m not knowing how to search for it. Spend a day and a half searching how to do it and still not working. Below some base code.

```julia
struct House
    Room::Int64 #20% 1 | 50% 2 | 20% 3 | 10% 4 or more
    Bathroom::Int64 #30% 1 | 50% 2 | 20% 3 or more
    Kitchen::Int64 #02% 0 | 98% 1
    LivingRoom::Int64 #30% 0 | 70% 1
    DiningRoom::Int64 #30% 0 | 70% 1
    Garage::Int64 #60% 0 | 40% 1
end

```

I really do need a direction here! Thanks in advance!!!

---

<div class="post-metadata">

**Author:** ![jw3126](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jw3126/32/3086_2.png) [@jw3126](https://discourse.julialang.org/u/jw3126)\
**Post date:** [August 26, 2021, 2:23pm UTC](https://discourse.julialang.org/t/generate-struct-based-on-stat-distribution/67040/2 "2021-08-26T14:23:34Z")

</div>

```julia
using Distributions

function random_house()
    Room = rand(Categorical([0.2, 0.5, 0.2, 0.1]))
    Bathroom = rand(...)
    ...
    return House(Room, Bathroom, ...)
end

```
