4th Street Bar Hive-Bar

Hive-Bar Powered by Hive beta-fdb5b5b

Community post

Day 4 ~ Custom Distribution : Controlling the Random

Day 4

This my fourth post on the 100 days of learning challenge I set myself.You can read more about this years goals here.

Last time I looked at how Normal Distrobution can make make random numbers consistently closer to the mean.

Let's customize the distribution a little.

Back to cacti, say we wanted to model a mature group of cacti that are all very tall.

cactus.jpg

We might create a function like this:

code.png

We would just push the first number if we wanted to model younger smaller cacti.

Here is a quick chart showing accumulated total of the two generated data sets:

chart.png

You can view the code behind the chart in the link below:

See the Pen Custom Distribution by Adam Harpur (@harps116) on CodePen.

As you can see the tall biased set contains significantly larger numbers than the smaller biased set.

Happy Coding!

Check out Daniel Shiffman's great series on the Nature of Code, this 100 days of learning is a great excuse for me to finally work through the lessons and take some notes as I go.

7 upvotes $0.11

Replies (0)

Conversation

No replies yet

Replies will appear here as people join the conversation.

Review before signing

Posting as . Signing with . Keychain permission: Posting. Hive Keychain will ask you to approve this action next.


  
Technical details

Operation fingerprint: