{"group":{"id":1,"name":"Community","lockable":false,"created_at":"2012-01-18T18:02:15.000Z","updated_at":"2025-12-14T01:33:56.000Z","description":"Problems submitted by members of the MATLAB Central community.","is_default":true,"created_by":161519,"badge_id":null,"featured":false,"trending":false,"solution_count_in_trending_period":0,"trending_last_calculated":"2025-12-14T00:00:00.000Z","image_id":null,"published":true,"community_created":false,"status_id":2,"is_default_group_for_player":false,"deleted_by":null,"deleted_at":null,"restored_by":null,"restored_at":null,"description_opc":null,"description_html":null,"published_at":null},"problems":[{"id":46657,"title":"Grouped Frequency Distributions","description":null,"description_html":"\u003cdiv style = \"text-align: start; line-height: 20.44px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: none solid rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 470px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 406.493px 235px; transform-origin: 406.493px 235px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 40px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 383.49px 20px; text-align: left; transform-origin: 383.498px 20px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eOne input is a dataset. The other input is the number of groups (classes). Create grouped frequency distribution by following steps:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 40px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 403.507px 20px; transform-origin: 403.507px 20px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1.11111px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1.11111px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1.11111px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1.11111px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 403.507px 10px; transform-origin: 403.507px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003edataset = [20,25,35,40,20,14,16,15,14,16,13,10,23,28,29,30,34,32,14,17,11,10,7,5,2,7,7];\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1.11111px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1.11111px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1.11111px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1.11111px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 403.507px 10px; transform-origin: 403.507px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003enumClass = 4;\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cul style=\"block-size: 80px; font-family: Helvetica, Arial, sans-serif; list-style-type: square; margin-block-end: 20px; margin-block-start: 10px; margin-bottom: 20px; margin-top: 10px; perspective-origin: 390.486px 40px; transform-origin: 390.495px 40px; margin-top: 10px; margin-bottom: 20px; \"\u003e\u003cli style=\"block-size: 20px; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 362.5px 10px; text-align: left; transform-origin: 362.5px 10px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eFind the range: max - min. range = 40 - 2 = 38\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 40px; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 362.5px 20px; text-align: left; transform-origin: 362.5px 20px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eFind the group (class) width by dividing the range by the number of groups. Round up if the width has decimal point. 38/4 = 9.5. round up. width = 10\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 20px; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 362.5px 10px; text-align: left; transform-origin: 362.5px 10px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eStart with the minimum value of the dataset and add class width.\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003c/ul\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 80px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 403.507px 40px; transform-origin: 403.507px 40px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1.11111px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1.11111px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1.11111px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1.11111px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 403.507px 10px; transform-origin: 403.507px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e2    12\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1.11111px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1.11111px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1.11111px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1.11111px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 403.507px 10px; transform-origin: 403.507px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e12   22\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1.11111px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1.11111px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1.11111px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1.11111px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 403.507px 10px; transform-origin: 403.507px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e22   32\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1.11111px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1.11111px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1.11111px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1.11111px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 403.507px 10px; transform-origin: 403.507px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e32   42\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cul style=\"block-size: 60px; font-family: Helvetica, Arial, sans-serif; list-style-type: square; margin-block-end: 20px; margin-block-start: 10px; margin-bottom: 20px; margin-top: 10px; perspective-origin: 390.486px 30px; transform-origin: 390.495px 30px; margin-top: 10px; margin-bottom: 20px; \"\u003e\u003cli style=\"display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 362.5px 30px; text-align: left; transform-origin: 362.5px 30px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eCount the number of occurrences in each group. For the first class you will count occurences greater than or equal to 2 and less than 12. For the second class you will count occurences greater than or equal to 12 and less than 22 and so on.\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003c/ul\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 100px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 403.507px 50px; transform-origin: 403.507px 50px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1.11111px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1.11111px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1.11111px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1.11111px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 403.507px 10px; transform-origin: 403.507px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003egroups     \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); text-decoration: none; text-decoration-color: rgb(170, 4, 249); \"\u003efrequency\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1.11111px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1.11111px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1.11111px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1.11111px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 403.507px 10px; transform-origin: 403.507px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e2    12       8\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1.11111px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1.11111px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1.11111px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1.11111px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 403.507px 10px; transform-origin: 403.507px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e12   22      10\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1.11111px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1.11111px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1.11111px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1.11111px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 403.507px 10px; transform-origin: 403.507px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e22   32       5\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1.11111px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1.11111px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1.11111px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1.11111px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 403.507px 10px; transform-origin: 403.507px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e32   42       4\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = groupedFreq(dataset,numClass)\r\n  y = x;\r\nend","test_suite":"%%\r\ndataset = [20 25 35 40 20 14 16 15 ...\r\n    14 16 13 10 23 28 29 30 34 32 ...\r\n    14 17 11 10 7 5 2 7 7 ];\r\nnumClass = 4;\r\ny_correct = [2,12,8;12,22,10;22,32,5;32,42,4];\r\nassert(isequal(groupedFreq(dataset,numClass),y_correct))\r\n\r\n%%\r\ndataset = [-52;5;2;-68;-74;-20;45;-43;-8;-59;15;-55;-19;8;35;45;-13;-71;-69;-54;28;-55;24;-56;41;-41;-63;-55;-4;-24;-41;27;-8;-13;39;-50;16;16;-37;-10;-80;-83;-16;19;41;-72;-10;-24;-89;-43];\r\nnumClass = 5;\r\ny_correct = [-89,-62,9;-62,-35,13;-35,-8,9;-8,19,9;19,46,10];\r\nassert(isequal(groupedFreq(dataset,numClass),y_correct))\r\n\r\n\r\n%%\r\ndataset = [138,0,69,64,69,116,48,118,71,5,26,108,71,23,51,91,28,111,36,138,40,115,28,43,13,87,103,82,64,97,97,102,96,142,31,107,35,18,91,67,69,99,116,52,99,62,127,125,38,92,87,81,131,39,48,18,141,97,72,96,82,97,82,108,78,150,33,15,16,9,61,67,55,115,94,116,140,146,28,20,105,14,79,80,130,73,59,101,111,78,52,22,88,39,6,113,36,66,103,54,111,59,103,106,66,2,49,64,40,29,124,64,134,59,116,59,122,114,56,32,119,143,49,101,66,125,116,25,130,149,77,133,88,23,30,61,113,124,119,48,80,13,16,20,102,74,28,74,22,8];\r\nnumClass = 4;\r\ny_correct = [0,38,34;38,76,42;76,114,43;114,152,31];\r\nassert(isequal(groupedFreq(dataset,numClass),y_correct))\r\n\r\n\r\n%%\r\ndataset = [-56;45;26;126;3;9;-74;-91;45;0;60;-51;173;30;104;2;7;75;64;-70;-103;-68;-93;25;-13;-9;-89;82;55;13;102;-50;53;48;48;-38;46;-21;-52;-76;103;-48;6;-77;-4;-239;-67;-94]\r\nnumClass = 5;\r\ny_correct = [-239,-156,1;-156,-73,8;-73,10,19;10,93,15;93,176,5];\r\nassert(isequal(groupedFreq(dataset,numClass),y_correct))\r\n\r\n\r\n\r\n%%\r\ndataset = [383;129;199;139;119;128;105;23;179;241;47;293;82;76;10;21;5;135;260;153;185;234;387;83;135;172;-30;-1;179;88;155;4;-63;176;219;263;-53;-34;-47;96;38;231;-46;-74;121;219;20;-27;85;-64;102;183;122;390;46;70;281;191;94;231;-4;65;241;250;173;149;41;174;17;157;128;214;57;164;179;10;116;260;111;69;146;72;144;87;98];\r\nnumClass = 5;\r\ny_correct =[-74,19,16;19,112,24;112,205,28;205,298,14;298,391,3];\r\nassert(isequal(groupedFreq(dataset,numClass),y_correct))","published":true,"deleted":false,"likes_count":1,"comments_count":2,"created_by":8703,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":11,"test_suite_updated_at":"2020-10-06T10:31:49.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2020-10-02T20:00:37.000Z","updated_at":"2026-03-17T07:36:44.000Z","published_at":"2020-10-03T06:47:51.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eOne input is a dataset. The other input is the number of groups (classes). Create grouped frequency distribution by following steps:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[dataset = [20,25,35,40,20,14,16,15,14,16,13,10,23,28,29,30,34,32,14,17,11,10,7,5,2,7,7];\\nnumClass = 4;]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFind the range: max - min. range = 40 - 2 = 38\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFind the group (class) width by dividing the range by the number of groups. Round up if the width has decimal point. 38/4 = 9.5. round up. width = 10\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eStart with the minimum value of the dataset and add class width.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[2    12\\n12   22\\n22   32\\n32   42]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCount the number of occurrences in each group. For the first class you will count occurences greater than or equal to 2 and less than 12. For the second class you will count occurences greater than or equal to 12 and less than 22 and so on.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[groups     frequency\\n2    12       8\\n12   22      10\\n22   32       5\\n32   42       4]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":44933,"title":"Vogel-Dobbener entropy","description":"*Vogel-Dobbener entropy* is a measure of dispersion for ordinal variables. \r\n\r\nGiven an ordered list of distinct observations u_(1), ..., u_(k) with observed relative frequencies f_1, ..., f_k, the Vogel-Dobbener entropy is defined as\r\n\r\n VD = -(sum_{i=1}^{k-1} (F_i log2(F_i) + (1 - F_i) log2(1 - F_i))\r\n\r\nwhere F_1, ... F_k are the cumulative relative frequences, i.e.\r\n\r\n F_i = sum_{j=1}^i f_i\r\n\r\nThe Vogel-Dobbener entropy of a sample satisfies 0 \u003c= VD \u003c= (k - 1); the normalized Vogel-Dobbener entropy is thus defined as\r\n\r\n VD* = VD / (k - 1)\r\n\r\n*For example*, suppose that your sample is [2.7 3.3 2.0 3.3 1.7 3.7]. Then:\r\n\r\n* k = 5 (there are five distinct observations);\r\n* u_(1), ..., u_(k) = [1.7 2.0 2.7 3.3 3.7]; (note that 3.3 only appears once);\r\n* f_1, ..., f_k = [1/6 1/6 1/6 2/6 1/6];\r\n* F_1, ..., F_k = [1/6 2/6 3/6 5/6 6/6];\r\n* VD = 3.2183; (approx.)\r\n* VD* = 0.8046. (approx.)\r\n\r\n*Your task* is to write a function that, given a list of observations (unordered and possibly containing duplicates) computes the normalized Vogel-Dobbener entropy VD* of the sample. *Round to four decimal digits.*\r\n\r\n*Hint*: if all observations in the sample are the same, then k = 1, the sum in the definition of VD is empty, and VD equals zero.","description_html":"\u003cp\u003e\u003cb\u003eVogel-Dobbener entropy\u003c/b\u003e is a measure of dispersion for ordinal variables.\u003c/p\u003e\u003cp\u003eGiven an ordered list of distinct observations u_(1), ..., u_(k) with observed relative frequencies f_1, ..., f_k, the Vogel-Dobbener entropy is defined as\u003c/p\u003e\u003cpre\u003e VD = -(sum_{i=1}^{k-1} (F_i log2(F_i) + (1 - F_i) log2(1 - F_i))\u003c/pre\u003e\u003cp\u003ewhere F_1, ... F_k are the cumulative relative frequences, i.e.\u003c/p\u003e\u003cpre\u003e F_i = sum_{j=1}^i f_i\u003c/pre\u003e\u003cp\u003eThe Vogel-Dobbener entropy of a sample satisfies 0 \u0026lt;= VD \u0026lt;= (k - 1); the normalized Vogel-Dobbener entropy is thus defined as\u003c/p\u003e\u003cpre\u003e VD* = VD / (k - 1)\u003c/pre\u003e\u003cp\u003e\u003cb\u003eFor example\u003c/b\u003e, suppose that your sample is [2.7 3.3 2.0 3.3 1.7 3.7]. Then:\u003c/p\u003e\u003cul\u003e\u003cli\u003ek = 5 (there are five distinct observations);\u003c/li\u003e\u003cli\u003eu_(1), ..., u_(k) = [1.7 2.0 2.7 3.3 3.7]; (note that 3.3 only appears once);\u003c/li\u003e\u003cli\u003ef_1, ..., f_k = [1/6 1/6 1/6 2/6 1/6];\u003c/li\u003e\u003cli\u003eF_1, ..., F_k = [1/6 2/6 3/6 5/6 6/6];\u003c/li\u003e\u003cli\u003eVD = 3.2183; (approx.)\u003c/li\u003e\u003cli\u003eVD* = 0.8046. (approx.)\u003c/li\u003e\u003c/ul\u003e\u003cp\u003e\u003cb\u003eYour task\u003c/b\u003e is to write a function that, given a list of observations (unordered and possibly containing duplicates) computes the normalized Vogel-Dobbener entropy VD* of the sample. \u003cb\u003eRound to four decimal digits.\u003c/b\u003e\u003c/p\u003e\u003cp\u003e\u003cb\u003eHint\u003c/b\u003e: if all observations in the sample are the same, then k = 1, the sum in the definition of VD is empty, and VD equals zero.\u003c/p\u003e","function_template":"function VDstar = vogel_dobbener_normalized(x)\r\n    VDstar = 0;\r\nend","test_suite":"%%\r\nx = [2.7 3.3 2.0 3.3 1.7 3.7];\r\nvds_correct = 0.8046;\r\nassert(isequal(vogel_dobbener_normalized(x), vds_correct))\r\n\r\n%%\r\nx = [linspace(0, 0, 5) linspace(1, 1, 20) linspace(2, 2, 43) linspace(3, 3, 13)];\r\nvds_correct = 0.6205;\r\nassert(isequal(vogel_dobbener_normalized(x), vds_correct))\r\n\r\n%%\r\nx = [linspace(10, 10, 4) linspace(11, 11, 17) linspace(99, 99, 38) linspace(7777, 7777, 22)];\r\nvds_correct = 0.6511;\r\nassert(isequal(vogel_dobbener_normalized(x), vds_correct))\r\n\r\n%%\r\nx = [-pi -pi -pi i i i];\r\nvds_correct = 1;\r\nassert(isequal(vogel_dobbener_normalized(x), vds_correct))\r\n\r\n%%\r\nx = [7777 7777 7777 7777 7777 7777];\r\nvds_correct = 0;\r\nassert(isequal(vogel_dobbener_normalized(x), vds_correct))\r\n\r\n","published":true,"deleted":false,"likes_count":4,"comments_count":0,"created_by":332395,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":12,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2019-07-08T09:39:50.000Z","updated_at":"2025-11-06T15:58:01.000Z","published_at":"2019-07-16T15:59:52.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eVogel-Dobbener entropy\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e is a measure of dispersion for ordinal variables.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven an ordered list of distinct observations u_(1), ..., u_(k) with observed relative frequencies f_1, ..., f_k, the Vogel-Dobbener entropy is defined as\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ VD = -(sum_{i=1}^{k-1} (F_i log2(F_i) + (1 - F_i) log2(1 - F_i))]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ewhere F_1, ... F_k are the cumulative relative frequences, i.e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ F_i = sum_{j=1}^i f_i]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe Vogel-Dobbener entropy of a sample satisfies 0 \u0026lt;= VD \u0026lt;= (k - 1); the normalized Vogel-Dobbener entropy is thus defined as\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ VD* = VD / (k - 1)]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eFor example\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, suppose that your sample is [2.7 3.3 2.0 3.3 1.7 3.7]. Then:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ek = 5 (there are five distinct observations);\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eu_(1), ..., u_(k) = [1.7 2.0 2.7 3.3 3.7]; (note that 3.3 only appears once);\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ef_1, ..., f_k = [1/6 1/6 1/6 2/6 1/6];\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eF_1, ..., F_k = [1/6 2/6 3/6 5/6 6/6];\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eVD = 3.2183; (approx.)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eVD* = 0.8046. (approx.)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eYour task\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e is to write a function that, given a list of observations (unordered and possibly containing duplicates) computes the normalized Vogel-Dobbener entropy VD* of the sample.\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eRound to four decimal digits.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eHint\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e: if all observations in the sample are the same, then k = 1, the sum in the definition of VD is empty, and VD equals zero.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"}],"problem_search":{"errors":[],"problems":[{"id":46657,"title":"Grouped Frequency Distributions","description":null,"description_html":"\u003cdiv style = \"text-align: start; line-height: 20.44px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: none solid rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 470px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 406.493px 235px; transform-origin: 406.493px 235px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 40px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 383.49px 20px; text-align: left; transform-origin: 383.498px 20px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eOne input is a dataset. The other input is the number of groups (classes). Create grouped frequency distribution by following steps:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 40px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 403.507px 20px; transform-origin: 403.507px 20px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1.11111px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1.11111px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1.11111px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1.11111px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 403.507px 10px; transform-origin: 403.507px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003edataset = [20,25,35,40,20,14,16,15,14,16,13,10,23,28,29,30,34,32,14,17,11,10,7,5,2,7,7];\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1.11111px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1.11111px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1.11111px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1.11111px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 403.507px 10px; transform-origin: 403.507px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003enumClass = 4;\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cul style=\"block-size: 80px; font-family: Helvetica, Arial, sans-serif; list-style-type: square; margin-block-end: 20px; margin-block-start: 10px; margin-bottom: 20px; margin-top: 10px; perspective-origin: 390.486px 40px; transform-origin: 390.495px 40px; margin-top: 10px; margin-bottom: 20px; \"\u003e\u003cli style=\"block-size: 20px; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 362.5px 10px; text-align: left; transform-origin: 362.5px 10px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eFind the range: max - min. range = 40 - 2 = 38\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 40px; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 362.5px 20px; text-align: left; transform-origin: 362.5px 20px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eFind the group (class) width by dividing the range by the number of groups. Round up if the width has decimal point. 38/4 = 9.5. round up. width = 10\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 20px; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 362.5px 10px; text-align: left; transform-origin: 362.5px 10px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eStart with the minimum value of the dataset and add class width.\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003c/ul\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 80px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 403.507px 40px; transform-origin: 403.507px 40px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1.11111px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1.11111px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1.11111px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1.11111px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 403.507px 10px; transform-origin: 403.507px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e2    12\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1.11111px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1.11111px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1.11111px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1.11111px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 403.507px 10px; transform-origin: 403.507px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e12   22\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1.11111px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1.11111px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1.11111px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1.11111px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 403.507px 10px; transform-origin: 403.507px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e22   32\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1.11111px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1.11111px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1.11111px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1.11111px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 403.507px 10px; transform-origin: 403.507px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e32   42\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cul style=\"block-size: 60px; font-family: Helvetica, Arial, sans-serif; list-style-type: square; margin-block-end: 20px; margin-block-start: 10px; margin-bottom: 20px; margin-top: 10px; perspective-origin: 390.486px 30px; transform-origin: 390.495px 30px; margin-top: 10px; margin-bottom: 20px; \"\u003e\u003cli style=\"display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 362.5px 30px; text-align: left; transform-origin: 362.5px 30px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eCount the number of occurrences in each group. For the first class you will count occurences greater than or equal to 2 and less than 12. For the second class you will count occurences greater than or equal to 12 and less than 22 and so on.\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003c/ul\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 100px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 403.507px 50px; transform-origin: 403.507px 50px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1.11111px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1.11111px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1.11111px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1.11111px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 403.507px 10px; transform-origin: 403.507px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003egroups     \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); text-decoration: none; text-decoration-color: rgb(170, 4, 249); \"\u003efrequency\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1.11111px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1.11111px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1.11111px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1.11111px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 403.507px 10px; transform-origin: 403.507px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e2    12       8\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1.11111px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1.11111px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1.11111px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1.11111px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 403.507px 10px; transform-origin: 403.507px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e12   22      10\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1.11111px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1.11111px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1.11111px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1.11111px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 403.507px 10px; transform-origin: 403.507px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e22   32       5\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1.11111px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1.11111px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1.11111px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1.11111px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 403.507px 10px; transform-origin: 403.507px 10px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e32   42       4\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = groupedFreq(dataset,numClass)\r\n  y = x;\r\nend","test_suite":"%%\r\ndataset = [20 25 35 40 20 14 16 15 ...\r\n    14 16 13 10 23 28 29 30 34 32 ...\r\n    14 17 11 10 7 5 2 7 7 ];\r\nnumClass = 4;\r\ny_correct = [2,12,8;12,22,10;22,32,5;32,42,4];\r\nassert(isequal(groupedFreq(dataset,numClass),y_correct))\r\n\r\n%%\r\ndataset = [-52;5;2;-68;-74;-20;45;-43;-8;-59;15;-55;-19;8;35;45;-13;-71;-69;-54;28;-55;24;-56;41;-41;-63;-55;-4;-24;-41;27;-8;-13;39;-50;16;16;-37;-10;-80;-83;-16;19;41;-72;-10;-24;-89;-43];\r\nnumClass = 5;\r\ny_correct = [-89,-62,9;-62,-35,13;-35,-8,9;-8,19,9;19,46,10];\r\nassert(isequal(groupedFreq(dataset,numClass),y_correct))\r\n\r\n\r\n%%\r\ndataset = [138,0,69,64,69,116,48,118,71,5,26,108,71,23,51,91,28,111,36,138,40,115,28,43,13,87,103,82,64,97,97,102,96,142,31,107,35,18,91,67,69,99,116,52,99,62,127,125,38,92,87,81,131,39,48,18,141,97,72,96,82,97,82,108,78,150,33,15,16,9,61,67,55,115,94,116,140,146,28,20,105,14,79,80,130,73,59,101,111,78,52,22,88,39,6,113,36,66,103,54,111,59,103,106,66,2,49,64,40,29,124,64,134,59,116,59,122,114,56,32,119,143,49,101,66,125,116,25,130,149,77,133,88,23,30,61,113,124,119,48,80,13,16,20,102,74,28,74,22,8];\r\nnumClass = 4;\r\ny_correct = [0,38,34;38,76,42;76,114,43;114,152,31];\r\nassert(isequal(groupedFreq(dataset,numClass),y_correct))\r\n\r\n\r\n%%\r\ndataset = [-56;45;26;126;3;9;-74;-91;45;0;60;-51;173;30;104;2;7;75;64;-70;-103;-68;-93;25;-13;-9;-89;82;55;13;102;-50;53;48;48;-38;46;-21;-52;-76;103;-48;6;-77;-4;-239;-67;-94]\r\nnumClass = 5;\r\ny_correct = [-239,-156,1;-156,-73,8;-73,10,19;10,93,15;93,176,5];\r\nassert(isequal(groupedFreq(dataset,numClass),y_correct))\r\n\r\n\r\n\r\n%%\r\ndataset = [383;129;199;139;119;128;105;23;179;241;47;293;82;76;10;21;5;135;260;153;185;234;387;83;135;172;-30;-1;179;88;155;4;-63;176;219;263;-53;-34;-47;96;38;231;-46;-74;121;219;20;-27;85;-64;102;183;122;390;46;70;281;191;94;231;-4;65;241;250;173;149;41;174;17;157;128;214;57;164;179;10;116;260;111;69;146;72;144;87;98];\r\nnumClass = 5;\r\ny_correct =[-74,19,16;19,112,24;112,205,28;205,298,14;298,391,3];\r\nassert(isequal(groupedFreq(dataset,numClass),y_correct))","published":true,"deleted":false,"likes_count":1,"comments_count":2,"created_by":8703,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":11,"test_suite_updated_at":"2020-10-06T10:31:49.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2020-10-02T20:00:37.000Z","updated_at":"2026-03-17T07:36:44.000Z","published_at":"2020-10-03T06:47:51.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eOne input is a dataset. The other input is the number of groups (classes). Create grouped frequency distribution by following steps:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[dataset = [20,25,35,40,20,14,16,15,14,16,13,10,23,28,29,30,34,32,14,17,11,10,7,5,2,7,7];\\nnumClass = 4;]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFind the range: max - min. range = 40 - 2 = 38\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFind the group (class) width by dividing the range by the number of groups. Round up if the width has decimal point. 38/4 = 9.5. round up. width = 10\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eStart with the minimum value of the dataset and add class width.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[2    12\\n12   22\\n22   32\\n32   42]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCount the number of occurrences in each group. For the first class you will count occurences greater than or equal to 2 and less than 12. For the second class you will count occurences greater than or equal to 12 and less than 22 and so on.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[groups     frequency\\n2    12       8\\n12   22      10\\n22   32       5\\n32   42       4]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":44933,"title":"Vogel-Dobbener entropy","description":"*Vogel-Dobbener entropy* is a measure of dispersion for ordinal variables. \r\n\r\nGiven an ordered list of distinct observations u_(1), ..., u_(k) with observed relative frequencies f_1, ..., f_k, the Vogel-Dobbener entropy is defined as\r\n\r\n VD = -(sum_{i=1}^{k-1} (F_i log2(F_i) + (1 - F_i) log2(1 - F_i))\r\n\r\nwhere F_1, ... F_k are the cumulative relative frequences, i.e.\r\n\r\n F_i = sum_{j=1}^i f_i\r\n\r\nThe Vogel-Dobbener entropy of a sample satisfies 0 \u003c= VD \u003c= (k - 1); the normalized Vogel-Dobbener entropy is thus defined as\r\n\r\n VD* = VD / (k - 1)\r\n\r\n*For example*, suppose that your sample is [2.7 3.3 2.0 3.3 1.7 3.7]. Then:\r\n\r\n* k = 5 (there are five distinct observations);\r\n* u_(1), ..., u_(k) = [1.7 2.0 2.7 3.3 3.7]; (note that 3.3 only appears once);\r\n* f_1, ..., f_k = [1/6 1/6 1/6 2/6 1/6];\r\n* F_1, ..., F_k = [1/6 2/6 3/6 5/6 6/6];\r\n* VD = 3.2183; (approx.)\r\n* VD* = 0.8046. (approx.)\r\n\r\n*Your task* is to write a function that, given a list of observations (unordered and possibly containing duplicates) computes the normalized Vogel-Dobbener entropy VD* of the sample. *Round to four decimal digits.*\r\n\r\n*Hint*: if all observations in the sample are the same, then k = 1, the sum in the definition of VD is empty, and VD equals zero.","description_html":"\u003cp\u003e\u003cb\u003eVogel-Dobbener entropy\u003c/b\u003e is a measure of dispersion for ordinal variables.\u003c/p\u003e\u003cp\u003eGiven an ordered list of distinct observations u_(1), ..., u_(k) with observed relative frequencies f_1, ..., f_k, the Vogel-Dobbener entropy is defined as\u003c/p\u003e\u003cpre\u003e VD = -(sum_{i=1}^{k-1} (F_i log2(F_i) + (1 - F_i) log2(1 - F_i))\u003c/pre\u003e\u003cp\u003ewhere F_1, ... F_k are the cumulative relative frequences, i.e.\u003c/p\u003e\u003cpre\u003e F_i = sum_{j=1}^i f_i\u003c/pre\u003e\u003cp\u003eThe Vogel-Dobbener entropy of a sample satisfies 0 \u0026lt;= VD \u0026lt;= (k - 1); the normalized Vogel-Dobbener entropy is thus defined as\u003c/p\u003e\u003cpre\u003e VD* = VD / (k - 1)\u003c/pre\u003e\u003cp\u003e\u003cb\u003eFor example\u003c/b\u003e, suppose that your sample is [2.7 3.3 2.0 3.3 1.7 3.7]. Then:\u003c/p\u003e\u003cul\u003e\u003cli\u003ek = 5 (there are five distinct observations);\u003c/li\u003e\u003cli\u003eu_(1), ..., u_(k) = [1.7 2.0 2.7 3.3 3.7]; (note that 3.3 only appears once);\u003c/li\u003e\u003cli\u003ef_1, ..., f_k = [1/6 1/6 1/6 2/6 1/6];\u003c/li\u003e\u003cli\u003eF_1, ..., F_k = [1/6 2/6 3/6 5/6 6/6];\u003c/li\u003e\u003cli\u003eVD = 3.2183; (approx.)\u003c/li\u003e\u003cli\u003eVD* = 0.8046. (approx.)\u003c/li\u003e\u003c/ul\u003e\u003cp\u003e\u003cb\u003eYour task\u003c/b\u003e is to write a function that, given a list of observations (unordered and possibly containing duplicates) computes the normalized Vogel-Dobbener entropy VD* of the sample. \u003cb\u003eRound to four decimal digits.\u003c/b\u003e\u003c/p\u003e\u003cp\u003e\u003cb\u003eHint\u003c/b\u003e: if all observations in the sample are the same, then k = 1, the sum in the definition of VD is empty, and VD equals zero.\u003c/p\u003e","function_template":"function VDstar = vogel_dobbener_normalized(x)\r\n    VDstar = 0;\r\nend","test_suite":"%%\r\nx = [2.7 3.3 2.0 3.3 1.7 3.7];\r\nvds_correct = 0.8046;\r\nassert(isequal(vogel_dobbener_normalized(x), vds_correct))\r\n\r\n%%\r\nx = [linspace(0, 0, 5) linspace(1, 1, 20) linspace(2, 2, 43) linspace(3, 3, 13)];\r\nvds_correct = 0.6205;\r\nassert(isequal(vogel_dobbener_normalized(x), vds_correct))\r\n\r\n%%\r\nx = [linspace(10, 10, 4) linspace(11, 11, 17) linspace(99, 99, 38) linspace(7777, 7777, 22)];\r\nvds_correct = 0.6511;\r\nassert(isequal(vogel_dobbener_normalized(x), vds_correct))\r\n\r\n%%\r\nx = [-pi -pi -pi i i i];\r\nvds_correct = 1;\r\nassert(isequal(vogel_dobbener_normalized(x), vds_correct))\r\n\r\n%%\r\nx = [7777 7777 7777 7777 7777 7777];\r\nvds_correct = 0;\r\nassert(isequal(vogel_dobbener_normalized(x), vds_correct))\r\n\r\n","published":true,"deleted":false,"likes_count":4,"comments_count":0,"created_by":332395,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":12,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2019-07-08T09:39:50.000Z","updated_at":"2025-11-06T15:58:01.000Z","published_at":"2019-07-16T15:59:52.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eVogel-Dobbener entropy\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e is a measure of dispersion for ordinal variables.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven an ordered list of distinct observations u_(1), ..., u_(k) with observed relative frequencies f_1, ..., f_k, the Vogel-Dobbener entropy is defined as\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ VD = -(sum_{i=1}^{k-1} (F_i log2(F_i) + (1 - F_i) log2(1 - F_i))]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ewhere F_1, ... F_k are the cumulative relative frequences, i.e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ F_i = sum_{j=1}^i f_i]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe Vogel-Dobbener entropy of a sample satisfies 0 \u0026lt;= VD \u0026lt;= (k - 1); the normalized Vogel-Dobbener entropy is thus defined as\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ VD* = VD / (k - 1)]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eFor example\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, suppose that your sample is [2.7 3.3 2.0 3.3 1.7 3.7]. Then:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ek = 5 (there are five distinct observations);\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eu_(1), ..., u_(k) = [1.7 2.0 2.7 3.3 3.7]; (note that 3.3 only appears once);\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ef_1, ..., f_k = [1/6 1/6 1/6 2/6 1/6];\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eF_1, ..., F_k = [1/6 2/6 3/6 5/6 6/6];\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eVD = 3.2183; (approx.)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eVD* = 0.8046. (approx.)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eYour task\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e is to write a function that, given a list of observations (unordered and possibly containing duplicates) computes the normalized Vogel-Dobbener entropy VD* of the sample.\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eRound to four decimal digits.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eHint\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e: if all observations in the sample are the same, then k = 1, the sum in the definition of VD is empty, and VD equals zero.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"}],"term":"tag:\"descriptive statistics\"","current_player_id":null,"fields":[{"name":"page","type":"integer","callback":null,"default":1,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"per_page","type":"integer","callback":null,"default":50,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"sort","type":"string","callback":null,"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"body","type":"text","callback":null,"default":"*:*","directive":null,"facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":false},{"name":"group","type":"string","callback":null,"default":null,"directive":"group","facet":true,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"difficulty_rating_bin","type":"string","callback":null,"default":null,"directive":"difficulty_rating_bin","facet":true,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"id","type":"integer","callback":null,"default":null,"directive":"id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"tag","type":"string","callback":null,"default":null,"directive":"tag","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"product","type":"string","callback":null,"default":null,"directive":"product","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"created_at","type":"timeframe","callback":{},"default":null,"directive":"created_at","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"profile_id","type":"integer","callback":null,"default":null,"directive":"author_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"created_by","type":"string","callback":null,"default":null,"directive":"author","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"player_id","type":"integer","callback":null,"default":null,"directive":"solver_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"player","type":"string","callback":null,"default":null,"directive":"solver","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"solvers_count","type":"integer","callback":null,"default":null,"directive":"solvers_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"comments_count","type":"integer","callback":null,"default":null,"directive":"comments_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"likes_count","type":"integer","callback":null,"default":null,"directive":"likes_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"leader_id","type":"integer","callback":null,"default":null,"directive":"leader_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"leading_solution","type":"integer","callback":null,"default":null,"directive":"leading_solution","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true}],"filters":[{"name":"asset_type","type":"string","callback":null,"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":"\"cody:problem\"","prepend":true},{"name":"profile_id","type":"integer","callback":{},"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":"author_id","static":null,"prepend":true}],"query":{"params":{"per_page":50,"term":"tag:\"descriptive statistics\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"descriptive statistics\"","","\"","descriptive statistics","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f4a0143c770\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f4a0143c6d0\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f4a0143be10\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f4a0143c9f0\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f4a0143c950\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f4a0143c8b0\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f4a0143c810\u003e":"tag:\"descriptive statistics\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f4a0143c810\u003e":"tag:\"descriptive statistics\""},"queried_facets":{}},"query_backend":{"connection":{"configuration":{"index_url":"http://index-op-v2/solr/","query_url":"http://search-op-v2/solr/","direct_access_index_urls":["http://index-op-v2/solr/"],"direct_access_query_urls":["http://search-op-v2/solr/"],"timeout":10,"vhost":"search","exchange":"search.topic","heartbeat":30,"pre_index_mode":false,"host":"rabbitmq-eks","port":5672,"username":"search","password":"J3bGPZzQ7asjJcCk","virtual_host":"search","indexer":"amqp","http_logging":"true","core":"cody"},"query_connection":{"uri":"http://search-op-v2/solr/cody/","proxy":null,"connection":{"parallel_manager":null,"headers":{"User-Agent":"Faraday v1.0.1"},"params":{},"options":{"params_encoder":"Faraday::FlatParamsEncoder","proxy":null,"bind":null,"timeout":null,"open_timeout":null,"read_timeout":null,"write_timeout":null,"boundary":null,"oauth":null,"context":null,"on_data":null},"ssl":{"verify":true,"ca_file":null,"ca_path":null,"verify_mode":null,"cert_store":null,"client_cert":null,"client_key":null,"certificate":null,"private_key":null,"verify_depth":null,"version":null,"min_version":null,"max_version":null},"default_parallel_manager":null,"builder":{"adapter":{"name":"Faraday::Adapter::NetHttp","args":[],"block":null},"handlers":[{"name":"Faraday::Response::RaiseError","args":[],"block":null}],"app":{"app":{"ssl_cert_store":{"verify_callback":null,"error":null,"error_string":null,"chain":null,"time":null},"app":{},"connection_options":{},"config_block":null}}},"url_prefix":"http://search-op-v2/solr/cody/","manual_proxy":false,"proxy":null},"update_format":"RSolr::JSON::Generator","update_path":"update","options":{"url":"http://search-op-v2/solr/cody"}}},"query":{"params":{"per_page":50,"term":"tag:\"descriptive statistics\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"descriptive statistics\"","","\"","descriptive statistics","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f4a0143c770\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f4a0143c6d0\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f4a0143be10\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f4a0143c9f0\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f4a0143c950\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f4a0143c8b0\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f4a0143c810\u003e":"tag:\"descriptive statistics\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f4a0143c810\u003e":"tag:\"descriptive statistics\""},"queried_facets":{}},"options":{"fields":["id","difficulty_rating"]},"join":" "},"results":[{"id":46657,"difficulty_rating":"easy"},{"id":44933,"difficulty_rating":"easy-medium"}]}}