Find the recurrence relation - discrete-mathematics

I'm new to recurrence relations and I'm having trouble figuring out this problem:
Find a recurrence relation for the number of ways to make a stack of green, yellow, and orange napkins so that no two green napkins are next to each other.
I've come up with a(n)=2a(n-1)+2a(n-2) but I'm not sure if that's right/ on the right track.
Any help would be great!

First of all, your answer is correct:
If the n'th napkin are green then n-1'th napkin could be yellow or orange and other n-2 napkin could be anything so it is 2*an-2.
If n'th napkin is not green it could be yellow or orange and other n-1 napkin could be anything so it is 2*an-1.
So the final answer is an = 2*an-2 + 2*an-1.

Related

Tableau: How do I calculate the proportion of one value as a percentage of another value, when the dimensions are in the rows

I'll lead by saying that I'm fairly new to Tableau and that I'm currently on version 9.1.
Here's the format of my data:
Date Color Fruit Value
1/1/2016 Red Apple 1
1/1/2016 Red Apple 2
1/1/2016 Red Pear 2
1/1/2016 Red Pear 3
1/2/2016 Green Apple 4
1/2/2016 Green Apple 2
1/2/2016 Green Pear 1
1/2/2016 Green Pear 2
How would I calculate the sum of Apples as a percentage of all Fruit? What about Red Apples as a Percentage of All Apples?
Please feel free to comment on how I can clean up this question, I know it's in bad shape. Thanks.
In order to show the % of a Total you should Right-click your measure and select Quick Table Calculation --> Percent of Total.
Example
Drag Furit on Rows and then Value on the Pane.
You should get:
Apple 9
Pear 8
Now you can add your quick table calculation and you'll get:
Apple 52,941%
Pear 47,059%
EDIT for Second Question
Dragging color in the rows shelf will update alle the %'s (of total).
If you want to see %'s by fruit, you just need to adjust the Computing type of your table calculation.
In order to do that, yo have to right click your measure and then click on "Compute Using" and then select Fruit.

Tableau: Adding Red and Green arrows to a column

I have 2 columns that I have in Tableau and one of them is date (Column A) and the other one is survey answer ( Satisfied, not satisfied, no comment). On the survey answer column I would like to indicate its growth over date (column A) using red or green arrow. Any thoughts on how I can to do that?
have you seen this post by Jonathan Drummey?
http://drawingwithnumbers.artisart.org/older-but-still-useful-conditional-formatting/

Change bar chart column structure

I change the column color in the bar chart but the problem that when i print the paper in black and white all columns look the same, so I am wondering if there is any way to change the column shape from inside (like cross or circles) so i can differentiate between columns in black and white ?
Thanks a lot
You may want to try, amongst others, this matlab exchange entry called Hatch fill patterns plus Color & Invert.

How to make it so that the whole fruit is white and the background is black

I have a to make an application that recognizes fruits. So far i have made that you can crop the image and get the color of the fruit you want. Now i am trying to get roundness of the fruit but i need the fruit to be black and the background to be white so i can find area and roundness value. This is my code so far for that part :
crop_temp = rgb2gray(crop);
threshold = graythresh(crop_temp);
bw = im2bw(crop_temp,threshold);
imshow(bw)
Crop i get passed when i crop the image. The problem gets when the fruit has a camera flash and that part stays white.
An example image is this lemon picture:
The problem is the white area in the lemon stays white after the code but i want it so that the whole lemon is black. But not just the lemon, but for other fruits to.
The problem is the white area in the lemon stays white after the code but i want it so that the whole lemon is black. But not just the lemon, but for other fruits to.
Yeah and how can you make so that the fruit is white and the background is black.
I am new to image processing so don't jump on me. I just can't find specific stuff for this.
Try this one:
fbw = ones(size(bw))-imfill(ones(size(bw))-bw);
imshow(fbw)
A brute force approach would be to check every white pixel in your image, and see if it is boxed in by black pixels in both the X and Y directions, turning it black if this is the case. This would take care of blobs inside your fruit, and shouldn't give you too many false-positives unless your fruit are strangely shaped, or you have a lot of noise around the edges of your image.
You can start by practicing with this Matlab demo, segmenting (and counting) rice in an image. In particular the part where the background is estimated.
Also helpful will be reading on Otsu's method and these two questions on background/foreground estimation on SO and DSP which take local statistics into account.

how to make stacked bar graph readable in white and black only

I have a stacked bar graph to include in my paper, which is going to be printed by reviewers in black and white only. When I print it out, I cannot tell the difference between some parts of it, which would otherwise be clearly distinguishable in color. Is there any way to make it readable even in black and white? Thanks in advance.
Have a look at the function presented in this File Exchange Pick of the Week to create hatched patterns instead of (or in addition to) your colors.
Here's one example:
Here's one example of how to use applyhatch_pluscolor:
figure, bar(rand(3,4)
[im_hatch,colorlist] = applyhatch_pluscolor(1,'|-.x',1,[1 0 1 1]);